Alphabatic filter in GridView using SQLDataSource |
|
Answered By
Moderator1
on
3/5/2010 8:48:22 PM |
|
|
|
|
Hi,
Please read the article in the below url to know the basic of Alphabetical Paging.
http://www.aspdotnetcodes.com/Asp.Net_Alphabetical_Paging_Control.aspx
Move to section titled as "Method 3: Create Alphabetic Pager with Stored Procedure". Alphabetical Paging in GridView can be easily done using Stored Procedures. I have given the sample code for you below,
<asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_ItemCommand"
RepeatDirection="Horizontal" DataSourceID="SqlDataSource1">
<SeparatorTemplate>
|
</SeparatorTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Bind("PageIndex") %>'
Text='<%# Bind("PageText") %>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestCnStr %>"
SelectCommand="Proc_Paging" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="2" Name="OptionId" />
</SelectParameters>
</asp:SqlDataSource>
I've called the Stored Procedure Proc_Paging from the SQLDataSource by passing parameter default value as "2". Then assign the DataSourceID of the DataList control as SQLDataSource1. Thats it. |
|
|
|