Hi All,
I have created a gridview at runtime.
I want to make the columns of the gridview sortable.
i am adding colums to the gridview columns dynamically by using the below code
gv.AllowSorting = true;
gv.RowCreated += new GridViewRowEventHandler(gv_RowCreated);
gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
gv.Sorting += new GridViewSortEventHandler(gv_Sorting);
if (gv.Columns.Count == 0)
{
foreach (DataColumn col in dtUserDetails.Columns)
{
TemplateField bfield = new TemplateField();
bfield.HeaderTemplate = new GridViewTemplate.GridViewTextTemplate(ListItemType.Header, col.ColumnName, col.DataType.Name);
bfield.ItemTemplate = new GridViewTemplate.GridViewTextTemplate(ListItemType.Item, col.ColumnName, col.DataType.Name);
bfield.EditItemTemplate = new GridViewTemplate.GridViewTextTemplate(ListItemType.EditItem, col.ColumnName, col.DataType.Name);
bfield.SortExpression = col.ColumnName;
gv.Columns.Add(bfield);
}
}
I have RowCreated, RowDataBound, and Sorting event handler for the gridview.
But the gridview column are not clickable for firing the sort event.
So what i need to do to make it sortable.
Thanks for your help in advance.