关于DataGrid(Web)多列排序后SelectedIndex和DataSetIndex的问题
我的datagrid有多列需要排序和分页,在点击一个linkbutton后需要打开一个新页面,显示当前选中的记录的详细信息,我给该页面传递的是选中的index。目前分页显示没有问题,但是排序以后,选择的index和数据集中的index对应不上,请那位大仙帮忙!急!!!
这是我的部分代码:
private void cluedatagrid_sortcommand(object source, system.web.ui.webcontrols.datagridsortcommandeventargs e)
{
try
{
this.cusservice=new exhibit.exwebapp.customerservice.customerservice();
dataset ds=this.cusservice.getcustomerdataset();
dataview dv=ds.tables["t014"].defaultview;
this.cluedatagrid.datasource=dv;
dv.sort=e.sortexpression;
this.cluedatagrid.databind();
}
catch(system.exception ex)
{
throw(ex);
}
}
//====================================================================================
//====================================================================================
private void cluedatagrid_pageindexchanged(object source, system.web.ui.webcontrols.datagridpagechangedeventargs e)
{
try
{
this.cluedatagrid.currentpageindex=e.newpageindex;
this.cluedatagrid.selectedindex=-1;
cluedatabind();
}
catch(system.exception ex)
{
page.registerstartupscript("open", "<script language=javascript> window.alert(数据排序发生意外或者数据绑定有误!请和管理员联系!);window.close();</script>");
throw(ex);
}
}
private void cluedatagrid_selectedindexchanged(object sender, system.eventargs e)
{
try
{
datagridselectedindex=this.cluedatagrid.selectedindex +this.cluedatagrid.currentpageindex*this.cluedatagrid.pagesize ;
strscriptscratch = "<script language=javascript>window.open(../customermanaged/customerm/viewcustomerclue.aspx?cusidindex="+datagridselectedindex+",_blank,,scrollbars=yes,status =yes,toolbar=no,left=40,top=40,width=590,height=480);</script>";
page.registerstartupscript("open", strscriptscratch);
}
catch(system.exception ex)
{
throw(ex);
}
}
//=====================================================================================
推荐阅读


讨论区