I am merging 2 rows in the column header of a Gridview. The row has to sort. To add the sorting ability to the column header I need to add the LinkButton control to the TableCell and then assign the Sorting method to the click event. I am getting the 'No overload for SectionGridView_Sorting...' I don't know how to add the event the the click action. This is the code:
TableCell cellSecID = new TableHeaderCell();
cellSecID.HorizontalAlign = HorizontalAlign.Center;
cellSecID.RowSpan = 2;
LinkButton lnkHeader = new LinkButton();
lnkHeader.PostBackUrl = HttpContext.Current.Request.Url.LocalPath;
lnkHeader.CommandArgument = "SectionID";
lnkHeader.Text = "SectionID";
lnkHeader.Click += new EventHandler(SectionGridView_Sorting); //This is the problem
cellSecID.Controls.Add(lnkHeader);
How to assign the Sorting method to the click event?
UPDATE This is my Sorting Method:
protected void SectionGridView_Sorting(object sender, GridViewSortEventArgs e)
{
//Get the CourseID
populateSectionGrid();
DataTable dtSectionGridData = SectionGridView.DataSource as DataTable;
SectionGridViewSortExpression = e.SortExpression;
if (dtSectionGridData != null)
{
DataView dataView = new DataView(dtSectionGridData);
dataView.Sort = SectionGridViewSortExpression + " " + ConvertSectionSortDirectionToSql(e.SortDirection);
SectionGridView.DataSource = dataView;
SectionGridView.DataBind();
}
}
The signature of the event-handler method isn't compatible with the delegate type.
Presumably you are binding LinkButton.Click
event with GridView Sorting
Event.
//section gridview should be like this
protected void SectionGridView_Sorting(object sender, GridViewSortEventArgs e)
{
}
However you need to bind with
void lnkHeader_Click(Object sender, EventArgs e)
{
}
If you don't have existing SectionGridView
sorting event then your lnkHeader
Click event should look this: (Not good practice though)
void SectionGridView_Sorting(Object sender, EventArgs e)
{
}