預先感謝您,請原諒此問題是否已被回答。item_databound正在兩次觸發
我想顯示記錄數。我在item_databound中放了一個計數器,注意到計數器是顯示記錄的兩倍。
我有一個數據訪問層處理數據網格爲:
Case "DataGrid"
If Len(DataValueField) > 0 Then
Dim oDS As New DataSet
Dim oDV As New DataView
oDV = DataTable.DefaultView
oDV.Sort = DataValueField & " ASC"
oDS.Tables.Add(oDV.ToTable)
CType(WebControl, DataGrid).DataSource = oDS
CType(WebControl, DataGrid).DataBind()
Else
CType(WebControl, DataGrid).DataSource = _DataSet
CType(WebControl, DataGrid).DataBind()
End If
CType(WebControl, DataGrid).DataSource = _DataSet
CType(WebControl, DataGrid).DataBind()
如果我使用自己Item_Databound在頁面上此代碼只運行一次:
Dim oDA As New SqlDataAdapter(SQL, _oConn)
Dim oDS As New DataSet
oDA.Fill(oDS)
grdUsers.DataSource = oDS
grdUsers.DataBind()
我在做什麼錯在我的DAL那是導致兩次發射?
感謝, Fudd語
對不起,不是更清晰。當我使用oDS運行數據集的代碼時,我沒有使用DAL代碼,即我創建的目標代碼。 – Stelmerfudd