Paging Paging Paging

I am trying to do paging with my search results and it isnt working very well.  Here is what I've tried and I feel I've tried everything, lol, please help me out.


Sub DataGrid1_SortCommand(Sender as object, e as DataGridSortCOmmandEventArgs)
DataGrid1.DataBind()
End Sub

Sub Datagrid1_PageIndexChanged(Sender as object, e as DataGridPageChangedEventArgs)
Dim ds as dataSet
DataGrid1.CurrentPageIndex = e.NewPageIndex
if Session("Search") is nothing then
'Session probably has expired, get the datasource from database

Datagrid1.DataSource = ds.Tables("tblItems")

else
ds = CType(Session("Search"), DataSet)
end if

End Sub


Sub Search(Sender as object, e as eventargs)

Dim strcol as String
Dim strQuery as String
strQuery = tbSearch.Text
Dim MyConnection as new oledbConnection("Provider=sqloledb;Data Source=KILLER-N68GZTBH\EMALL;Initial Catalog=EMALL;User Id=sa;Password=ma_rie1;")
Dim myCOmmand as new oledbDataAdapter("Select * FROM tblItems WHERE ItemKeywords LIKE '%" & strQuery & "%'", MyConnection)
Dim ds as Dataset = new dataset()
MyCommand.Fill(ds, "tblItems")
Session("SearchQuery") = ds
DataGrid1.Datasource = ds.Tables("tblItems").DefaultView
DataBind()
strCol = tbSearch.Text
Dim SearchcOmmand as New oledbCommand("INsert INTO tblSearch (SearchQuery) Values ('" & strcol & "')", MyCOnnection)


MyConnection.Open
SearchCommand.ExecuteNonQuery
MyConnection.CLose

End Sub

And my datagrid

<asp:DataGrid id="Datagrid1"
runat="server"
BorderColor="#6666ff"
Gridlines="Horizontal"
Cellpadding="0"
CellSpacing="0"
Width="75%"
Font-Names="Arial"
Font-Size="10pt"
ShowFooter="True"
HeaderStyle-BackCOlor="#6666ff"
FooterStyle-Backcolor="#6666ff"
ItemStyle-BackColor="#99ccff"
AlternatingItemStyle-BackCOlor="#CCCCFF"
AutoGenerateCOlumns="False"
ALLOWPaging="True"
PageSize="1"
PagerStyle="NextPrev"
OnPAgeIndexXhanged="Datagrid1_PageIndexChanged"
AllowSorting="True">
<Columns>
<asp:TemplateColumn HeaderTExt="Link">
<ItemTemplate>
<asp:HyperLink NavigateURL='<%# "items.aspx?UserID=" & Container.DataItem("UserID") & "&StoreID=" & Container.DataItem("StoreID") & "&ItemID=" & Container.DataItem("ItemID") %>' runat="server" Text="Check it out" />
</ItemTEmplate>
</asp:TemplateColumn>

<asp:templateColumn HeaderTExt="Image">
<ItemTemplate>
<asp:Image IMaGeUrl='<%# "~/Images/" & Container.DataItem("UserID") & "/" & Container.DataItem("ItemPicture") %>' Height="100" Width="100" runat="server" />
</ItemTEmplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Item Name" Datafield="ItemName" />
<asp:TemplateColumn HeaderText="Description">
<ItemTEmplate>
<asp:label id="lblDescription" runat="server" Text='<%# Container.DataItem("ItemDescription") %>' />
</ItemTEmplate>
</asp:TemplateColumn>
<asp:BOundColumn HeaderTExt="Price" Datafield="ItemPrice" />
<asp:BoundCOlumn HeaderText="Quantity Left" DataField="ItemQuantity" />
</Columns>
</asp:DataGrid>

            
Free pixel advertising
0
markmil2002
12/20/2004 7:22:23 AM
📁 asp.net.presentation-controls
📃 72751 articles.
⭐ 3 followers.

💬 2 Replies
👁️‍🗨️ 3687 Views


In the paging event, after you update it's currentPageIndex, the grid needs to be rebound to the datasource.  So you should write code to rebind it or call a function that binds the grid.

In this world there are 10 types of people, those that know binary and those who don't.
0
optik
12/20/2004 1:42:03 PM
I dont understand exactly what you mean

Free pixel advertising
0
markmil2002
12/20/2004 3:51:54 PM
Reply: