Hello,
I have an embedded datagrid inside a repeater whose datasource i set in the repeater's ItemDataBound event handler. My question is this: if i want to make the datagrid sortable do i initialise the datagrid's SortCommand in the same place where i set it's datasource? If my repeater is called repeater and my datagrid is called dataGrid then what i currently have is this:
This doesnt work and my dataGrid_SortCommand method is never being called.
Does anyone know what's wrong with this?
I have an embedded datagrid inside a repeater whose datasource i set in the repeater's ItemDataBound event handler. My question is this: if i want to make the datagrid sortable do i initialise the datagrid's SortCommand in the same place where i set it's datasource? If my repeater is called repeater and my datagrid is called dataGrid then what i currently have is this:
Code:
private void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if( (item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem) )
{
dataGrid = (DataGrid) item.FindControl("dataGrid");
dataGrid.DataSource = GetDataSrouce();
dataGrid.DataBind();
dataGrid.SortCommand+=new DataGridSortCommandEventHandler(dataGrid_SortCommand); [i]//does this belong here?[/i]
}
}
This doesnt work and my dataGrid_SortCommand method is never being called.
Does anyone know what's wrong with this?