如题用了gridview自带的分页代码
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = JL;
GridView1.DataBind();
}
然后在RowDataBound中
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = e.Row.Cells[0].Text;
e.Row.Attributes.Add("ondblclick", "location.href='../record/detail.aspx?Id=" + id + "'");
}
e.Row.Cells[0].Text; 第一页还没问题,翻页以后就取不到值了
求大佬帮忙
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = JL;
GridView1.DataBind();
}
然后在RowDataBound中
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = e.Row.Cells[0].Text;
e.Row.Attributes.Add("ondblclick", "location.href='../record/detail.aspx?Id=" + id + "'");
}
e.Row.Cells[0].Text; 第一页还没问题,翻页以后就取不到值了
求大佬帮忙
解决方案 »
- SqlParameter的问题
- C# 单击右键时,如何获得光标的位置
- C#中如何实现SAT格式文件的重建?
- datagridview
- C# PDA通过WebService调用电子地图,并能进行平移,缩放,定位。
- 微软的dotnet程序调用sun的java写的*.class组件,哪为大侠知道如何做?请指点下小弟。。谢谢
- 如何让label接收键盘事件
- 请问webconfig连接数据库
- 刚学 数据库数据不能更新不能删除 请大侠多指教
- 对于写C/S结构的程序,VS中有没有非常良好的结构,类似Borland一样的
- 如何才能保证同一个线程下的两个方法输出的值一样
- C# 中 webbrowser控件,下载时不弹出保存提示框,直接转向了下载的URL 没有实现下载 求解决方案
还是说string id = e.Row.Cells[0].Text; 句有问题?那你给个翻页后取值的句子啊
随便自定义属性='<%# GetABC((string)Eval("DataID")) %>'
OnClick="Button1_Click" />这里就为输出的<input type="button"> 元素自定义了一个“随便自定义属性”的属性,然后可以用页面上的protected string GetABC(string key)
{
return .........
}来计算任意复杂的输出文本(比如说一个 url)。首选地是学会设计模板,而不是写什么 c# 代码。要写 c# 代码你就得先把底层的原理和数据结构搞懂,不能乱猜数据来源。
DataRowView drv = (DataRowView)e.Row.DataItem;
string id = drv["ID"].ToString();
不行啊报错,DataBinding:“MODEL.record”不包含名为“id”的属性。
无法将类型为“MODEL.record”的对象强制转换为类型“System.Data.DataRowView”。
事件中
if (e.Row.RowType == DataControlRowType.DataRow)
中
e.Row.Cells[x].Text;在取值列隐藏的情况下是取不到值的。
在前台gridview里加DataKeyNames="xxx",xxx为取值列名
后台
string x = GridView1.DataKeys[e.Row.RowIndex].Values["xxx"].ToString();
或string x = DataBinder.Eval(e.Row.DataItem, "xxx").ToString();
就可以取到值了
最讨厌你们这群说话说一半的人装什么优越感,吔屎嘞