Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a DataGrid inside a Repeater

Status
Not open for further replies.

shades44

Programmer
Jun 14, 2004
25
CA
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:

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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top