65.9K
CodeProject is changing. Read more.
Home

WebDataGridPaging Problem Solving

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.37/5 (6 votes)

Feb 26, 2006

1 min read

viewsIcon

19155

downloadIcon

144

About web datagrid paging problem

Sample Image - 1.gif

Introduction

If you use webdatagrid on your web project think more than once. Because webdatagrid has got a lot of problems. For example; I used webdatagrid for search page. I am sending my keyword with querystring and catch this querystring on search.aspx. I have no problem from first step to this step. What the this step is ?? You guess Paging Problem....... When I execute my query from sqlclient it is working for first page but when i want to change another page it is gave errors. I started to think and also research all the internet about webdatagrid. And last i found my problem. This problems solved with traditional metots. My datagrid's code here:

<asp:datagrid id="dgBulunanListe" runat="server" DataKeyField="mutaalaid" AutoGenerateColumns="False"
GridLines="Vertical" CellPadding="4" BackColor="red" BorderWidth="0px" BorderStyle="None"
BorderColor="#000000" Width="950px" AllowPaging="True" ForeColor="#000000">
<SelectedItemStyle Font-Bold="True" ForeColor="#FFFFFF" BackColor="#CCCCCC"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#FFFFFF"></AlternatingItemStyle>
<ItemStyle BackColor="#EBEBEB"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#CCCCCC"></HeaderStyle>
<FooterStyle BackColor="#CCCC99"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="MutaalaID" HeaderStyle-Width="50" HeaderText="Mütalaa ID" HeaderStyle-ForeColor="#000000"></asp:BoundColumn>
<asp:BoundColumn DataField="MutaalaSecilenTarihi" HeaderStyle-Width="110" HeaderText="Mütalaa Tarihi"></asp:BoundColumn>
<asp:BoundColumn DataField="MutaalaBaslik" HeaderText="Mütalaa Başlık"></asp:BoundColumn>
<asp:HyperLinkColumn Text="Git >>" HeaderStyle-Width="40" DataNavigateUrlField="MutaalaID" DataNavigateUrlFormatString="MutaalaDetay.aspx?MutaalaID={0}"
HeaderText="Sonuçlar"></asp:HyperLinkColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="Black" Position="TopAndBottom" BackColor="#CCCCCC"
Mode="NumericPages"></PagerStyle>
</asp:datagrid>
This datagrid is binding if the web page is not making postback.
This metot(FilitreYap()) is using for hidding search criterions like keyword or level of search bla bla. Why we are putting this variable to hidden field ?? Just why we can't use static variable.. I tried it but it is not a solution because this application is working internet. Variables always problem so if we are using web,we must know and must use web language its know HTML.
Practically i put the variables on hidden fields and then i gave these variables from this fields. When i am binding this datagrid how i gave this values from hidden fields.
And the last event is datagrid page index changed event. This event for binding for every changed pages of datagrid.