protected void gv_IsPopular_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{ LinkButton up =e.Row.FindControl("linkbtn_Up") as LinkButton;
LinkButton down = e.Row.FindControl("linkbtn_down") as LinkButton;
if (whetherLine == 1)
{
up.Enabled = false;
}
whetherLine++;
if (whetherLine == a.Rows.Count)
{
down.Enabled = false;
}
}
}
提示: if (whetherLine == 1)
{
up.Enabled = false; 未将对象引用设置到对象的实例
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{ LinkButton up =e.Row.FindControl("linkbtn_Up") as LinkButton;
LinkButton down = e.Row.FindControl("linkbtn_down") as LinkButton;
if (whetherLine == 1)
{
up.Enabled = false;
}
whetherLine++;
if (whetherLine == a.Rows.Count)
{
down.Enabled = false;
}
}
}
提示: if (whetherLine == 1)
{
up.Enabled = false; 未将对象引用设置到对象的实例
}
解决方案 »
- 如何取得视图中的字段,select * from syscolumns where id = object_id('XT_JCDW')
- 哪位大神看看问题啊
- mvc displayFor换行的问题
- session 数组问题
- 【100分】 请教水晶报表的批量打印方案
- asp.net 中的datagrid的数据一片空白
- 如何在web页面(.aspx)中嵌套word、excel、frontpage编辑器?
- 日期格式转换的问题
- 请教高手:怎么样将DataGrid中的数据导入到excel中?
- 如何解决这种问题,我经常碰到,谢谢
- 关于事件的问题,谢谢!
- 急~!!!急~!!!!!急~!!!!!!!!!!!!VSS操作~!!1
--
看看是不是ID写错了
{
LinkButton up = (LinkButton)gvi.FindControl("linkbtn_Up");
LinkButton down = (LinkButton)gvi.FindControl("linkbtn_down");
if (whetherLine == 1)
{
up.Enabled = false;
}
whetherLine++;
if (whetherLine == gvi.Count)
{
down.Enabled = false;
}
}
linkbtn_Up是在ItemTemplate还是EditItemTemplate中
up肯定没有找到,最好在使用之前判断一下是否null然后再处理
否则就会"未将对象引用设置到对象的实例 "
LinkButton down = e.Row.FindControl("linkbtn_down") as LinkButton;
if (whetherLine == 1)
{
if(up!=null)
up.Enabled = false;
}
whetherLine++;
if (whetherLine == a.Rows.Count)
{
if(down!=null)
down.Enabled = false;
}