N
nish
Hi,
I have been working on Sorting within a Datagrid that is created
programmatically, so everything is created in the code-behind.
I have a Template Column that consists of a Header Template. The
Header Template consists of LinkButtons, so when triggered it will fire
an event calling the following function:
e.CommandName - contains "Sort1", "Sort2", etc.
protected void Epot_Command(object sender, CommandEventArgs e)
{
Response.Write("link button clicked");
int buttonClicked = Convert.ToInt32(e.CommandName.Remove(0,4));
this.sortString = "Col" + buttonClicked.ToString();
// sort data
DataView dataView = this.dt.DefaultView;
dataView.Sort = sortString + " DESC";
this.EpotDG.DataSource = dataView;
this.EpotDG.DataBind();
}
So to sort my data, I have a dataView which I obtained from the
DataTable. The variable "sortString" contains the Column names,
such as Col1, Col2 - this is obtained from the xml file.
<Col1>Benefits</Col1>
<Col2>Benefit Areas</Col2>
Everything is working, however the dataRows are not being sorted.
Please advise how to proceed.
Many thanks..
nish
I have been working on Sorting within a Datagrid that is created
programmatically, so everything is created in the code-behind.
I have a Template Column that consists of a Header Template. The
Header Template consists of LinkButtons, so when triggered it will fire
an event calling the following function:
e.CommandName - contains "Sort1", "Sort2", etc.
protected void Epot_Command(object sender, CommandEventArgs e)
{
Response.Write("link button clicked");
int buttonClicked = Convert.ToInt32(e.CommandName.Remove(0,4));
this.sortString = "Col" + buttonClicked.ToString();
// sort data
DataView dataView = this.dt.DefaultView;
dataView.Sort = sortString + " DESC";
this.EpotDG.DataSource = dataView;
this.EpotDG.DataBind();
}
So to sort my data, I have a dataView which I obtained from the
DataTable. The variable "sortString" contains the Column names,
such as Col1, Col2 - this is obtained from the xml file.
<Col1>Benefits</Col1>
<Col2>Benefit Areas</Col2>
Everything is working, however the dataRows are not being sorted.
Please advise how to proceed.
Many thanks..
nish