Hi Guys,
I have a datagrid wit editing and updating.
But after adding Paging IT WON'T PAGE!!
It compiles well but when i click on the paging link it doesn't go to the
next link..
When i remove AllowCutomPagin g it gives error:-
"AllowCustomPag ing must be true and VirtualItemCoun t must be set for a
DataGrid with ID MenuGrid when AllowPaging is set to true and the selected
datasource does not implement ICollection"
My code is below for reference THANKS!
---------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
MenuGrid.Virtua lItemCount = 200
' Databind the data grid on the first request only
' (on postback, bind only in editing, paging and sorting commands)
BindDataGrid()
End If
End Sub
Sub BindDataGrid()
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String
DBConnection = New
SqlConnection(" server=(local); database=Northw ind;integrated security=true;" )
DBConnection.Op en()
'SQLString = "SELECT * FROM Products1 ORDER BY ItemNumber"
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection)
DBReader = DBCommand.Execu teReader()
MenuGrid.DataSo urce = DBReader
MenuGrid.DataBi nd()
DBReader.Close( )
DBConnection.Cl ose()
End Sub
Sub EditRecord(ByVa l Src As Object, ByVal Args As
DataGridCommand EventArgs)
MenuGrid.EditIt emIndex = Args.Item.ItemI ndex
BindDataGrid()
End Sub
Sub UpdateRecord(By Val Src As Object, ByVal Args As
DataGridCommand EventArgs)
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String
' Dim ItemNumber = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text
' Dim ItemSupplier = CType(Args.Item .Cells(1).Contr ols(0),
TextBox).Text
' Dim ItemType = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text
' Dim ItemName = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text
'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0),
TextBox).Text
Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0),
TextBox).Text
Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text
Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text
Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text
Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'SQLString = "UPDATE treetable SET " & _
'"ParentID = '" & ParentID & "', " & _
'"FileCatego ry = '" & FileCategory & "', " & _
'"NavigateUr l = '" & NavigateUrl & "', " & _
'"Target = '" & Target & "' WHERE FileCategoryID ='" &
FileCategoryID & "'"
SQLString = "UPDATE treetable SET " & _
"ParentID = '" & ParentID & "', " & _
"FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _
"NavigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _
"Target = '" & Target & "' " & _
"WHERE FileCategoryID ='" & FileCategoryID & "'"
'SQLString = "UPDATE Products1 SET " & _
' "ItemType = '" & ItemType & "', " & _
' "ItemSuppli er = '" & Replace(ItemSup plier, "'", "''") &
"', " & _
' "ItemName = '" & Replace(ItemNam e, "'", "''") & "', " & _
' "ItemPrice = " & ItemPrice & ", " & _
' "ItemQuanti ty = " & ItemQuantity & " " & _
' "WHERE ItemNumber = '" & ItemNumber & "'"
DBConnection = New
SqlConnection(" server=(local); database=Northw ind;integrated security=true;" )
DBConnection.Op en()
DBCommand = New SqlCommand(SQLS tring, DBConnection)
DBCommand.Execu teNonQuery()
DBConnection.Cl ose()
MenuGrid.EditIt emIndex = -1
BindDataGrid()
End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As
DataGridCommand EventArgs)
MenuGrid.EditIt emIndex = -1
BindDataGrid()
End Sub
Sub MenuGrid_Page(B yVal Sender As Object, ByVal E As
DataGridPageCha ngedEventArgs)
MenuGrid.Curren tPageIndex = E.NewPageIndex
BindDataGrid()
End Sub
End Class
-----------------------------------------------------
<asp:DataGrid id="MenuGrid" runat="server"
OnEditCommand=" EditRecord"
OnUpdateCommand ="UpdateReco rd"
OnCancelCommand ="CancelReco rd"
AutoGenerateCol umns="False"
Width="700"
BackColor="#ccc cff"
BorderColor="bl ack"
ShowFooter="fal se"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaa add"
AlternatingItem Style-BackColor="#fff fcc"
CssClass="P"
OnPageIndexChan ged="MenuGrid_P age"
PageSize="2"
AllowPaging="Tr ue"
AllowCustomPagi ng="true"> 5 1700
Well, just adding Paging doesn't do the trick fo ryou.
You also need to add the function that will set the page Index
I suggest you take a look at the Event called PageIndexChange d on the
DataGrid
/Lars
"Patrick.O. Ige" <Pa*********@di scussions.micro soft.com> skrev i meddelandet
news:6B******** *************** ***********@mic rosoft.com... Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove AllowCutomPagin g it gives error:- "AllowCustomPag ing must be true and VirtualItemCoun t must be set for a DataGrid with ID MenuGrid when AllowPaging is set to true and the selected datasource does not implement ICollection"
My code is below for reference THANKS!
--------------------------------------------------------------------------
- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then MenuGrid.Virtua lItemCount = 200
' Databind the data grid on the first request only ' (on postback, bind only in editing, paging and sorting
commands) BindDataGrid()
End If
End Sub Sub BindDataGrid()
Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated
security=true;" ) DBConnection.Op en() 'SQLString = "SELECT * FROM Products1 ORDER BY ItemNumber"
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection) DBReader = DBCommand.Execu teReader() MenuGrid.DataSo urce = DBReader MenuGrid.DataBi nd() DBReader.Close( ) DBConnection.Cl ose()
End Sub
Sub EditRecord(ByVa l Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = Args.Item.ItemI ndex BindDataGrid() End Sub
Sub UpdateRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
' Dim ItemNumber = CType(Args.Item .Cells(0).Contr ols(0),
TextBox).Text ' Dim ItemSupplier = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text ' Dim ItemType = CType(Args.Item .Cells(2).Contr ols(0),
TextBox).Text ' Dim ItemName = CType(Args.Item .Cells(3).Contr ols(0),
TextBox).Text 'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0),
TextBox).Text 'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0), TextBox).Text
Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0),
TextBox).Text Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0),
TextBox).Text Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'SQLString = "UPDATE treetable SET " & _ '"ParentID = '" & ParentID & "', " & _ '"FileCatego ry = '" & FileCategory & "', " & _ '"NavigateUr l = '" & NavigateUrl & "', " & _ '"Target = '" & Target & "' WHERE FileCategoryID ='" & FileCategoryID & "'"
SQLString = "UPDATE treetable SET " & _ "ParentID = '" & ParentID & "', " & _ "FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _ "NavigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _ "Target = '" & Target & "' " & _ "WHERE FileCategoryID ='" & FileCategoryID & "'" 'SQLString = "UPDATE Products1 SET " & _ ' "ItemType = '" & ItemType & "', " & _ ' "ItemSuppli er = '" & Replace(ItemSup plier, "'", "''") & "', " & _ ' "ItemName = '" & Replace(ItemNam e, "'", "''") & "', " & _ ' "ItemPrice = " & ItemPrice & ", " & _ ' "ItemQuanti ty = " & ItemQuantity & " " & _ ' "WHERE ItemNumber = '" & ItemNumber & "'"
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated
security=true;" ) DBConnection.Op en() DBCommand = New SqlCommand(SQLS tring, DBConnection) DBCommand.Execu teNonQuery() DBConnection.Cl ose()
MenuGrid.EditIt emIndex = -1 BindDataGrid()
End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = -1 BindDataGrid() End Sub Sub MenuGrid_Page(B yVal Sender As Object, ByVal E As DataGridPageCha ngedEventArgs) MenuGrid.Curren tPageIndex = E.NewPageIndex BindDataGrid() End Sub End Class ----------------------------------------------------- <asp:DataGrid id="MenuGrid" runat="server" OnEditCommand=" EditRecord" OnUpdateCommand ="UpdateReco rd" OnCancelCommand ="CancelReco rd" AutoGenerateCol umns="False" Width="700" BackColor="#ccc cff" BorderColor="bl ack" ShowFooter="fal se" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaa add" AlternatingItem Style-BackColor="#fff fcc" CssClass="P" OnPageIndexChan ged="MenuGrid_P age" PageSize="2" AllowPaging="Tr ue" AllowCustomPagi ng="true">
Hi Lars,
I have a Dataset in the same way with paging and its working fine..
Can u refer an example to me..
thanks
"Lars Netzel" wrote: Well, just adding Paging doesn't do the trick fo ryou.
You also need to add the function that will set the page Index
I suggest you take a look at the Event called PageIndexChange d on the DataGrid
/Lars "Patrick.O. Ige" <Pa*********@di scussions.micro soft.com> skrev i meddelandet news:6B******** *************** ***********@mic rosoft.com... Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove AllowCutomPagin g it gives error:- "AllowCustomPag ing must be true and VirtualItemCoun t must be set for a DataGrid with ID MenuGrid when AllowPaging is set to true and the selected datasource does not implement ICollection"
My code is below for reference THANKS!
-------------------------------------------------------------------------- - Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then MenuGrid.Virtua lItemCount = 200
' Databind the data grid on the first request only ' (on postback, bind only in editing, paging and sorting commands) BindDataGrid()
End If
End Sub Sub BindDataGrid()
Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated
security=true;" ) DBConnection.Op en() 'SQLString = "SELECT * FROM Products1 ORDER BY ItemNumber"
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection) DBReader = DBCommand.Execu teReader() MenuGrid.DataSo urce = DBReader MenuGrid.DataBi nd() DBReader.Close( ) DBConnection.Cl ose()
End Sub
Sub EditRecord(ByVa l Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = Args.Item.ItemI ndex BindDataGrid() End Sub
Sub UpdateRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
' Dim ItemNumber = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text ' Dim ItemSupplier = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text ' Dim ItemType = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text ' Dim ItemName = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text 'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text 'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0), TextBox).Text
Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'SQLString = "UPDATE treetable SET " & _ '"ParentID = '" & ParentID & "', " & _ '"FileCatego ry = '" & FileCategory & "', " & _ '"NavigateUr l = '" & NavigateUrl & "', " & _ '"Target = '" & Target & "' WHERE FileCategoryID ='" & FileCategoryID & "'"
SQLString = "UPDATE treetable SET " & _ "ParentID = '" & ParentID & "', " & _ "FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _ "NavigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _ "Target = '" & Target & "' " & _ "WHERE FileCategoryID ='" & FileCategoryID & "'" 'SQLString = "UPDATE Products1 SET " & _ ' "ItemType = '" & ItemType & "', " & _ ' "ItemSuppli er = '" & Replace(ItemSup plier, "'", "''") & "', " & _ ' "ItemName = '" & Replace(ItemNam e, "'", "''") & "', " & _ ' "ItemPrice = " & ItemPrice & ", " & _ ' "ItemQuanti ty = " & ItemQuantity & " " & _ ' "WHERE ItemNumber = '" & ItemNumber & "'"
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated security=true;" ) DBConnection.Op en() DBCommand = New SqlCommand(SQLS tring, DBConnection) DBCommand.Execu teNonQuery() DBConnection.Cl ose()
MenuGrid.EditIt emIndex = -1 BindDataGrid()
End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = -1 BindDataGrid() End Sub Sub MenuGrid_Page(B yVal Sender As Object, ByVal E As DataGridPageCha ngedEventArgs) MenuGrid.Curren tPageIndex = E.NewPageIndex BindDataGrid() End Sub End Class ----------------------------------------------------- <asp:DataGrid id="MenuGrid" runat="server" OnEditCommand=" EditRecord" OnUpdateCommand ="UpdateReco rd" OnCancelCommand ="CancelReco rd" AutoGenerateCol umns="False" Width="700" BackColor="#ccc cff" BorderColor="bl ack" ShowFooter="fal se" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaa add" AlternatingItem Style-BackColor="#fff fcc" CssClass="P" OnPageIndexChan ged="MenuGrid_P age" PageSize="2" AllowPaging="Tr ue" AllowCustomPagi ng="true">
Hi Lars,
I have a Dataset in the same way with paging and its working fine..
Can u refer an example to me..
thanks
"Lars Netzel" wrote: Well, just adding Paging doesn't do the trick fo ryou.
You also need to add the function that will set the page Index
I suggest you take a look at the Event called PageIndexChange d on the DataGrid
/Lars "Patrick.O. Ige" <Pa*********@di scussions.micro soft.com> skrev i meddelandet news:6B******** *************** ***********@mic rosoft.com... Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove AllowCutomPagin g it gives error:- "AllowCustomPag ing must be true and VirtualItemCoun t must be set for a DataGrid with ID MenuGrid when AllowPaging is set to true and the selected datasource does not implement ICollection"
My code is below for reference THANKS!
-------------------------------------------------------------------------- - Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then MenuGrid.Virtua lItemCount = 200
' Databind the data grid on the first request only ' (on postback, bind only in editing, paging and sorting commands) BindDataGrid()
End If
End Sub Sub BindDataGrid()
Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated
security=true;" ) DBConnection.Op en() 'SQLString = "SELECT * FROM Products1 ORDER BY ItemNumber"
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection) DBReader = DBCommand.Execu teReader() MenuGrid.DataSo urce = DBReader MenuGrid.DataBi nd() DBReader.Close( ) DBConnection.Cl ose()
End Sub
Sub EditRecord(ByVa l Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = Args.Item.ItemI ndex BindDataGrid() End Sub
Sub UpdateRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
' Dim ItemNumber = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text ' Dim ItemSupplier = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text ' Dim ItemType = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text ' Dim ItemName = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text 'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text 'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0), TextBox).Text
Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'SQLString = "UPDATE treetable SET " & _ '"ParentID = '" & ParentID & "', " & _ '"FileCatego ry = '" & FileCategory & "', " & _ '"NavigateUr l = '" & NavigateUrl & "', " & _ '"Target = '" & Target & "' WHERE FileCategoryID ='" & FileCategoryID & "'"
SQLString = "UPDATE treetable SET " & _ "ParentID = '" & ParentID & "', " & _ "FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _ "NavigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _ "Target = '" & Target & "' " & _ "WHERE FileCategoryID ='" & FileCategoryID & "'" 'SQLString = "UPDATE Products1 SET " & _ ' "ItemType = '" & ItemType & "', " & _ ' "ItemSuppli er = '" & Replace(ItemSup plier, "'", "''") & "', " & _ ' "ItemName = '" & Replace(ItemNam e, "'", "''") & "', " & _ ' "ItemPrice = " & ItemPrice & ", " & _ ' "ItemQuanti ty = " & ItemQuantity & " " & _ ' "WHERE ItemNumber = '" & ItemNumber & "'"
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated security=true;" ) DBConnection.Op en() DBCommand = New SqlCommand(SQLS tring, DBConnection) DBCommand.Execu teNonQuery() DBConnection.Cl ose()
MenuGrid.EditIt emIndex = -1 BindDataGrid()
End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = -1 BindDataGrid() End Sub Sub MenuGrid_Page(B yVal Sender As Object, ByVal E As DataGridPageCha ngedEventArgs) MenuGrid.Curren tPageIndex = E.NewPageIndex BindDataGrid() End Sub End Class ----------------------------------------------------- <asp:DataGrid id="MenuGrid" runat="server" OnEditCommand=" EditRecord" OnUpdateCommand ="UpdateReco rd" OnCancelCommand ="CancelReco rd" AutoGenerateCol umns="False" Width="700" BackColor="#ccc cff" BorderColor="bl ack" ShowFooter="fal se" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaa add" AlternatingItem Style-BackColor="#fff fcc" CssClass="P" OnPageIndexChan ged="MenuGrid_P age" PageSize="2" AllowPaging="Tr ue" AllowCustomPagi ng="true">
Hi Lars,
I have a Dataset in the same way with paging and its working fine..
Can u refer an example to me..
thanks
"Lars Netzel" wrote: Well, just adding Paging doesn't do the trick fo ryou.
You also need to add the function that will set the page Index
I suggest you take a look at the Event called PageIndexChange d on the DataGrid
/Lars "Patrick.O. Ige" <Pa*********@di scussions.micro soft.com> skrev i meddelandet news:6B******** *************** ***********@mic rosoft.com... Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove AllowCutomPagin g it gives error:- "AllowCustomPag ing must be true and VirtualItemCoun t must be set for a DataGrid with ID MenuGrid when AllowPaging is set to true and the selected datasource does not implement ICollection"
My code is below for reference THANKS!
-------------------------------------------------------------------------- - Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then MenuGrid.Virtua lItemCount = 200
' Databind the data grid on the first request only ' (on postback, bind only in editing, paging and sorting commands) BindDataGrid()
End If
End Sub Sub BindDataGrid()
Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated
security=true;" ) DBConnection.Op en() 'SQLString = "SELECT * FROM Products1 ORDER BY ItemNumber"
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection) DBReader = DBCommand.Execu teReader() MenuGrid.DataSo urce = DBReader MenuGrid.DataBi nd() DBReader.Close( ) DBConnection.Cl ose()
End Sub
Sub EditRecord(ByVa l Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = Args.Item.ItemI ndex BindDataGrid() End Sub
Sub UpdateRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
' Dim ItemNumber = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text ' Dim ItemSupplier = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text ' Dim ItemType = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text ' Dim ItemName = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text 'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text 'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0), TextBox).Text
Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'SQLString = "UPDATE treetable SET " & _ '"ParentID = '" & ParentID & "', " & _ '"FileCatego ry = '" & FileCategory & "', " & _ '"NavigateUr l = '" & NavigateUrl & "', " & _ '"Target = '" & Target & "' WHERE FileCategoryID ='" & FileCategoryID & "'"
SQLString = "UPDATE treetable SET " & _ "ParentID = '" & ParentID & "', " & _ "FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _ "NavigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _ "Target = '" & Target & "' " & _ "WHERE FileCategoryID ='" & FileCategoryID & "'" 'SQLString = "UPDATE Products1 SET " & _ ' "ItemType = '" & ItemType & "', " & _ ' "ItemSuppli er = '" & Replace(ItemSup plier, "'", "''") & "', " & _ ' "ItemName = '" & Replace(ItemNam e, "'", "''") & "', " & _ ' "ItemPrice = " & ItemPrice & ", " & _ ' "ItemQuanti ty = " & ItemQuantity & " " & _ ' "WHERE ItemNumber = '" & ItemNumber & "'"
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated security=true;" ) DBConnection.Op en() DBCommand = New SqlCommand(SQLS tring, DBConnection) DBCommand.Execu teNonQuery() DBConnection.Cl ose()
MenuGrid.EditIt emIndex = -1 BindDataGrid()
End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = -1 BindDataGrid() End Sub Sub MenuGrid_Page(B yVal Sender As Object, ByVal E As DataGridPageCha ngedEventArgs) MenuGrid.Curren tPageIndex = E.NewPageIndex BindDataGrid() End Sub End Class ----------------------------------------------------- <asp:DataGrid id="MenuGrid" runat="server" OnEditCommand=" EditRecord" OnUpdateCommand ="UpdateReco rd" OnCancelCommand ="CancelReco rd" AutoGenerateCol umns="False" Width="700" BackColor="#ccc cff" BorderColor="bl ack" ShowFooter="fal se" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaa add" AlternatingItem Style-BackColor="#fff fcc" CssClass="P" OnPageIndexChan ged="MenuGrid_P age" PageSize="2" AllowPaging="Tr ue" AllowCustomPagi ng="true">
Hi Lars,
I have a Dataset in the same way with paging and its working fine..
Can u refer an example to me..
thanks
"Lars Netzel" wrote: Well, just adding Paging doesn't do the trick fo ryou.
You also need to add the function that will set the page Index
I suggest you take a look at the Event called PageIndexChange d on the DataGrid
/Lars "Patrick.O. Ige" <Pa*********@di scussions.micro soft.com> skrev i meddelandet news:6B******** *************** ***********@mic rosoft.com... Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove AllowCutomPagin g it gives error:- "AllowCustomPag ing must be true and VirtualItemCoun t must be set for a DataGrid with ID MenuGrid when AllowPaging is set to true and the selected datasource does not implement ICollection"
My code is below for reference THANKS!
-------------------------------------------------------------------------- - Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then MenuGrid.Virtua lItemCount = 200
' Databind the data grid on the first request only ' (on postback, bind only in editing, paging and sorting commands) BindDataGrid()
End If
End Sub Sub BindDataGrid()
Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated
security=true;" ) DBConnection.Op en() 'SQLString = "SELECT * FROM Products1 ORDER BY ItemNumber"
SQLString = "SELECT * FROM treetable ORDER BY FileCategoryID"
DBCommand = New SqlCommand(SQLS tring, DBConnection) DBReader = DBCommand.Execu teReader() MenuGrid.DataSo urce = DBReader MenuGrid.DataBi nd() DBReader.Close( ) DBConnection.Cl ose()
End Sub
Sub EditRecord(ByVa l Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = Args.Item.ItemI ndex BindDataGrid() End Sub
Sub UpdateRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim DBReader As SqlDataReader Dim SQLString As String
' Dim ItemNumber = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text ' Dim ItemSupplier = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text ' Dim ItemType = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text ' Dim ItemName = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text 'Dim ItemPrice = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text 'Dim ItemQuantity = CType(Args.Item .Cells(5).Contr ols(0), TextBox).Text
Dim FileCategoryID = CType(Args.Item .Cells(0).Contr ols(0), TextBox).Text Dim ParentID = CType(Args.Item .Cells(1).Contr ols(0), TextBox).Text Dim FileCategory = CType(Args.Item .Cells(2).Contr ols(0), TextBox).Text Dim NavigateUrl = CType(Args.Item .Cells(3).Contr ols(0), TextBox).Text Dim Target = CType(Args.Item .Cells(4).Contr ols(0), TextBox).Text
'SQLString = "UPDATE treetable SET " & _ '"ParentID = '" & ParentID & "', " & _ '"FileCatego ry = '" & FileCategory & "', " & _ '"NavigateUr l = '" & NavigateUrl & "', " & _ '"Target = '" & Target & "' WHERE FileCategoryID ='" & FileCategoryID & "'"
SQLString = "UPDATE treetable SET " & _ "ParentID = '" & ParentID & "', " & _ "FileCatego ry = '" & Replace(FileCat egory, "'", "''") & "', " & _ "NavigateUr l = '" & Replace(Navigat eUrl, "'", "''") & "', " & _ "Target = '" & Target & "' " & _ "WHERE FileCategoryID ='" & FileCategoryID & "'" 'SQLString = "UPDATE Products1 SET " & _ ' "ItemType = '" & ItemType & "', " & _ ' "ItemSuppli er = '" & Replace(ItemSup plier, "'", "''") & "', " & _ ' "ItemName = '" & Replace(ItemNam e, "'", "''") & "', " & _ ' "ItemPrice = " & ItemPrice & ", " & _ ' "ItemQuanti ty = " & ItemQuantity & " " & _ ' "WHERE ItemNumber = '" & ItemNumber & "'"
DBConnection = New SqlConnection(" server=(local); database=Northw ind;integrated security=true;" ) DBConnection.Op en() DBCommand = New SqlCommand(SQLS tring, DBConnection) DBCommand.Execu teNonQuery() DBConnection.Cl ose()
MenuGrid.EditIt emIndex = -1 BindDataGrid()
End Sub
Sub CancelRecord(By Val Src As Object, ByVal Args As DataGridCommand EventArgs) MenuGrid.EditIt emIndex = -1 BindDataGrid() End Sub Sub MenuGrid_Page(B yVal Sender As Object, ByVal E As DataGridPageCha ngedEventArgs) MenuGrid.Curren tPageIndex = E.NewPageIndex BindDataGrid() End Sub End Class ----------------------------------------------------- <asp:DataGrid id="MenuGrid" runat="server" OnEditCommand=" EditRecord" OnUpdateCommand ="UpdateReco rd" OnCancelCommand ="CancelReco rd" AutoGenerateCol umns="False" Width="700" BackColor="#ccc cff" BorderColor="bl ack" ShowFooter="fal se" CellPadding=3 CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaa add" AlternatingItem Style-BackColor="#fff fcc" CssClass="P" OnPageIndexChan ged="MenuGrid_P age" PageSize="2" AllowPaging="Tr ue" AllowCustomPagi ng="true"> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RelaxoRy |
last post by:
sqlConnection1.Open();
myReader = sqlCommand1.ExecuteReader();
DataGrid1.DataSource = myReader;
DataGrid1.DataBind();
myReader.Close();
sqlConnection1.Close();
The Datagrid populates fine. I'm styling it on the HTML page. I
configure the DataGrid for paging through the property builder fine.
I AllowCustomePaging=true;. The page loads...
|
by: Joseph D. DeJohn |
last post by:
I am trying to get pagination working on a datagrid. Can anyone point me to
a resource for help on this? I'm not sure if custom paging is the best
option or not.
|
by: enak |
last post by:
I can not get my datagrid to page. I have a datagrid that
I can sort 2 of the columns. This works great. I added
paging and when I display the dg it shows 5 pages. (I am
showing page numbers at the bottom of the dg.)
When I click on the pages nothing happens until I get to
the last page. Then and only then is the last page
displayed. If I...
|
by: RJN |
last post by:
Hi
Sorry for posting again.
I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has to be scrolled down completely to see the page number
links. The page number should always be visible outside the scroll bar.
Basically I want to...
|
by: Shawn |
last post by:
Hi.
I already have a datagrid where I'm using paging. I have a stored procedure
that fills a temp table with 200-500 rows and then sends back 10 records at
the time. When I go to page 2 the SP fills the temp table again and returns
rows 10-19. The temp table is dropped after each call to the SP, so it has
to be created and filled every...
| |
by: quanga |
last post by:
Hi-
I have a datagrid that in some cases can be several thousand rows in
length. What I'd like it to do is have the data pushed to the browser
after every, say, 100 rows or so. Kind of a "response.flush" effect--
at a certain recurring point in the process, take what we've got and
send it to the browser. Is this possible?
Thanks.
|
by: Axel Dahmen |
last post by:
Hi,
I'm using a DataGrid control to show a table's content with paging. For
navigation through the pages I'm using the DataGrid's intrinsic navigation
section.
My problem: The DataGrid navigation links use JavaScript to jump between
pages. I want them to use standard hyperlinks providing the page number in
some URL parameter so that I...
|
by: tshad |
last post by:
Is there a way to carry data that I have already read from the datagrid from
page to page?
I am looking at my Datagrid that I page through and when the user says get
the next page, I have to go to the database to get the next page. Is there
a way to use the dataset to allow us to read back and forth in it instead of
going back to the...
|
by: Pat |
last post by:
I have 3 Datagrid nested.
Master
Details
Child
The master has paging (And i'm using the paging inbuilt in the Datagrid)
in the Master DataGrid you select a linkbutton(using commandname) and it
populates the data in the Details DataGrid
(I'm using Dim Filter As String =
CStr(dtgMaster.DataKeys(dtgMaster.SelectedIndex)).Replace("'", "''") ...
|
by: Pat |
last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i
populate the Child databrid using myDataGrid.SelectedIndex value
as the filter and setting the DataKeyField.
I enabled paging for the MasterDataGrid which works well but when i page to
the next set of rows and select a particular ROW(for example SHOW DETAILS)
to...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |