0

グリッド ビューを使用して pageindexchaning と pageindexchanged を有効にしています 20 ページのうち 1,2,3,4,5 にいくつかの値を入力しました。追加時にいくつかのテキスト ボックスの値があり、1 ページだけから値を読み取っています。合計ページ数が不足しています..しかし、すべてのページ行を読み取る必要があります.あなたの助けが必要です..ページの読み込み時に、このコードを書きました..

    Dim sname As String = Session("Current_user")

    If (TextBox3.Text <> "") Then
        TextBox3.Text = ""
    End If
    Button1.BackColor = Drawing.Color.White

    Dim con As connect_comp = New connect_comp()
    ocompany = CType(HttpContext.Current.Session("company"), SAPbobsCOM.Company)
    'Dim myConnection As SqlConnection
    'Dim ConfigStr As String = ConfigurationManager.ConnectionStrings("PayrollConnectionString").ConnectionString
    'myConnection = New SqlConnection(ConfigStr)
    'myConnection.Open()

    Dim RS1 As SAPbobsCOM.Recordset
    RS1 = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
    RS1.DoQuery("select t1.U_ItmCde,t1.U_ItmDes,t1.U_ItmNme,t1.U_UOM    from  [@TI_VITHDR] t0 inner join  [@TI_VITLNE] t1 on  t0.Code =t1.Code  where t0.U_Whse='" & sname & "'")


    Dim dt As New DataTable()
    Dim dr As DataRow = Nothing
    dt.Columns.Add(New DataColumn("SNO", GetType(String)))
    dt.Columns.Add(New DataColumn("ItemName", GetType(String)))
    dt.Columns.Add(New DataColumn("ItemCode", GetType(String)))
    dt.Columns.Add(New DataColumn("Item Description", GetType(String)))
    dt.Columns.Add(New DataColumn("UOM", GetType(String)))

    For i As Integer = 1 To RS1.RecordCount
        dr = dt.NewRow()

        dr("SNO") = i
        dr("ItemName") = RS1.Fields.Item("U_ItmDes").Value
        dr("ItemCode") = RS1.Fields.Item("U_ItmCde").Value
        dr("Item Description") = RS1.Fields.Item("U_ItmNme").Value
        dr("UOM") = RS1.Fields.Item("U_UOM").Value
        dt.Rows.Add(dr)
        RS1.MoveNext()
    Next


    ViewState("CurrentTable") = dt
    Gridview1.DataSource = dt
    Gridview1.DataBind()

-------------------------
page index and page index changed i have written 
Protected Sub Gridview1_PageIndexChanging(ByVal sender As Object, ByVal e As    GridViewPageEventArgs)
    'Session("Test") = Gridview1
    'Gridview1 = Nothing
    'Gridview1.PageIndex = e.NewPageIndex
    'SetInitialRow()
    Response.Write(Gridview1.PageIndex.ToString())
    Dim d As Integer = Gridview1.PageCount
    Dim texts As String() = New String(Gridview1.PageSize - 1) {}
    Dim texts1 As String() = New String(Gridview1.PageSize - 1) {}
    Dim textBox, textBox1 As TextBox
    Dim count As Integer = 0
    For Each row As GridViewRow In Gridview1.Rows
        textBox = DirectCast(row.FindControl("TextBox1"), TextBox)
        textBox1 = DirectCast(row.FindControl("TextBox2"), TextBox)
        If textBox IsNot Nothing Then
            texts(count) = textBox.Text
        Else
            texts(count) = ""
        End If


        If textBox1 IsNot Nothing Then
            texts1(count) = textBox1.Text
        Else
            texts1(count) = ""
        End If
        count += 1

    Next
    Session("page" + Gridview1.PageIndex.ToString()) = texts
    Session("page1" + Gridview1.PageIndex.ToString()) = texts1
    Gridview1.PageIndex = e.NewPageIndex
    SetInitialRow()
End Sub
Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    If Session("page" + Gridview1.PageIndex.ToString) IsNot Nothing Then
        Dim textBox As TextBox
        Dim texts As String() = DirectCast(Session("page" + Gridview1.PageIndex.ToString()), String())
        For i As Integer = 0 To Gridview1.Rows.Count - 1
            textBox = DirectCast(Gridview1.Rows(i).FindControl("TextBox1"), TextBox)
            textBox.Text = texts(i)
        Next
    End If

    If Session("page1" + Gridview1.PageIndex.ToString) IsNot Nothing Then
        Dim textBox1 As TextBox
        Dim texts1 As String() = DirectCast(Session("page1" + Gridview1.PageIndex.ToString()), String())
        For i As Integer = 0 To Gridview1.Rows.Count - 1
            textBox1 = DirectCast(Gridview1.Rows(i).FindControl("TextBox2"), TextBox)
            textBox1.Text = texts1(i)
        Next
    End If
End Sub
----------

追加している間、私はカウントしていますTry Dim Cnt1、Rowcnt1 As Integer Rowcnt1 = Gridview1.Rows.Count For Cnt1 = 0 To Rowcnt1 - 1

ここで、グリッド行全体が必要な1ページの値のみを読み取るという問題が発生します。任意の体plzは私にいくつかの提案を与えることができます..

4

1 に答える 1

0

SQL を使用してデータベースにクエリを実行しているため、合計行数 =

select Count(*) from  [@TI_VITHDR] t0 inner join  [@TI_VITLNE] t1 on  t0.Code =t1.Code  where t0.U_Whse='" & sname & "'"
于 2013-09-05T13:22:20.243 に答える