how to sort column in template field in gridview(ASP.NET)

Posted by Cvbharathi89 under DotNetFunda.Com on 4/22/2012 | Points: 10 | Views : 3136 | Status : [Member] | Replies : 2
Sir,
i searched many site to sort a value in template field in grid view but no use, i hope your team will help me , please assist me to sort the column in grid view, here i write my source and code behind code please Reply me with how to include sorting code with this code,Thanks in Advance.

bharathi.c.v


Responses

Posted by: Gsm_Gsv on: 4/22/2012 [Member] Starter | Points: 25

Up
0
Down
Where is the datasourceID for gridview?

compare with the below code.. If you face any problem, let me know

 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 

AllowSorting="True" BorderStyle="None" DataKeyNames="Title"
DataSourceID="ObjectDataSource1" EmptyDataText="No Data Found" Font-Bold="True"
OnRowCommand="GridView1_RowCommand" PageSize="5" Visible="False" Width="62%">
<PagerSettings PageButtonCount="5" Position="Top" />
<RowStyle BackColor="#66FFFF" HorizontalAlign="Center" VerticalAlign="Middle" />
<EmptyDataRowStyle ForeColor="Red" />
<Columns>
<asp:BoundField />
<asp:TemplateField>
<HeaderTemplate>
Delete
</HeaderTemplate>
<ItemTemplate>
<asp:Button ID="BtnDelete" runat="server" CommandArgument='<%#Eval("Title")%>'
CommandName="Del"
OnClientClick="return confirm('Are you sure you want to delete this record?');"
Text="Delete" />
<asp:Button ID="BtnEdit" runat="server" CommandArgument='<%#Eval("Title") %>'
CommandName="edit" Text="Edit" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<PagerStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle BackColor="#FF9966" />
<EditRowStyle BackColor="White" HorizontalAlign="Center"
VerticalAlign="Middle" />
<AlternatingRowStyle BackColor="White" HorizontalAlign="Center"
VerticalAlign="Middle" />
</asp:GridView>


---------------------------------------
Live the life you've dreamed

Regards
MADHU

Cvbharathi89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Cvbharathi89 on: 4/22/2012 [Member] Starter | Points: 25

Up
0
Down
Sir,
Thanks for your reply, i have questioned with my code please download from DATA SOURCE FILE which is below my Question line , please reply with sorting code in both Source code and Code Behind Code.


bharathi.c.v

Cvbharathi89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response