Hi, All:
I dynamic add an arrow up/down image in OnItemDataBound event for my
datagrid, it works fine. But I have another textbox which trigger
postback and doing something, after this event get executed, I lost the
image but the datagrid maintain the same sort order. Should the
datagrid remain what it looks like (with the riget arrow up/down image)
before the postback caused by the textbox?
I tried to get the datagrid header in the text postback event
(OnChanged), but I do not know how to get the datagrid header. I do not
want to rebind the datagrid in the textbox OnChanged event.
Or should I use other method to show the sort direction image?
private void dgrid_OnItemDat aBound(object sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
//Sorting Image
if(e.Item.ItemT ype == ListItemType.He ader)
{
foreach(TableCe ll tc in e.Item.Cells)
{
if(tc.Controls. Count > 0)
{
try
{
LinkButton lkbSortCol =
(System.Web.UI. WebControls.Lin kButton)tc.Cont rols[0];
if(lkbSortCol.C ommandArgument. ToString().Equa ls(dgrid.Attrib utes["SortExpre*ssio n"]))
{
System.Web.UI.W ebControls.Imag e imgSort = new
System.Web.UI.W ebControls.Imag e();
if(dgrid.Attrib utes["SortDirect ion"].Equals("DESC") )
{
imgSort.ImageUr l = Server.MapPath( "Images/sort_desc.gif") ;
}
else
{
imgSort.ImageUr l = Server.MapPath( "Images/sort_asc.gif");
}
tc.Controls.Add At(1,
imgSort);
}
}
catch(Exception ex)
{
Trace.Write(ex. Message);
}
}//end if tc.controls.cou nt > 0
}//end for
} //end item type
Thanks a lot
-Rockdale