I'm currently using Gridview to display some data from SQL however having problem with allowing users to sort the data. Here's what I got:
code behind:
on page_load, I do some data manipulation like this:
When user click on the column title to sort, the page is posted back with the same set of data but all the data manipulation I did on page_load is lost.
Any help is appreciated. I'm a beginner.
Thanks
GQ
Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ServiceNowDB %>"
ProviderName="<%$ ConnectionStrings:ServiceNowDB.ProviderName %>"
SelectCommand="SELECT [number], [request_item], [assigned_to], [state], [subscriber], [room_num], [request_type], [deploy_type], [due_date], [item_sysid], [task_sysid] FROM [sc_tasks_updated] WHERE ([state] NOT LIKE '%' + ? + '%')">
<SelectParameters>
<asp:Parameter DefaultValue="Closed" Name="state" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None"
EnableSortingAndPagingCallbacks="false">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="number" HeaderText="Number"
SortExpression="number" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
..... more asp:BoundFields.....
</Columns>
</asp:GridView>
on page_load, I do some data manipulation like this:
Code:
protected void Page_Load(object sender, EventArgs e)
{
string takslink = "http://www.domain.com/task.list?id=2343";
thisRow.Cells[0].Text = "<a href=\"" + tasklink + "\">" + thisRow.Cells[0].Text + "</a>";
thisRow.Cells[4].Text = thisRow.Cells[4].Text.Replace(":", "");
}
Any help is appreciated. I'm a beginner.
Thanks
GQ