给GridView里的Label赋值 Label lbl = (Label )this.gvSelect.FindControl("Num");int a =Convert.ToInt32(lbl.text);---------------------------------未将对象引用设置到对象的实例。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 lbl.Text大写 顺便说一下 我写在 rtProduct_ItemCommand里 有关系吗? 貌似不是大小写问题,是压根没找到Label的问题,如果是大小写顶多报个Label不含有text属性,他这报的是未将对象引用设置到对象的实例,说明压根没找到Label。你确定你gridview里面的Label叫Num? [Quote=引用 7 楼 ziyouli 的回复:]貌似不是大小写问题,是压根没找到Label的问题,如果是大小写顶多报个Label不含有text属性,他这报的是未将对象引用设置到对象的实例,说明压根没找到Label。你确定你gridview里面的Label叫Num?[/ <asp:GridView ID="gvSelect" runat="server" AutoGenerateColumns="False" DataKeyNames="Pro_Id" onrowdeleting="gvSelect_RowDeleting" onrowdatabound="gvSelect_RowDataBound"> <Columns> <asp:BoundField DataField="Pro_Id" HeaderText="产品编号" InsertVisible="False" ReadOnly="True" SortExpression="Pro_Id" /> <asp:BoundField DataField="Pro_Name" HeaderText="已点菜单" SortExpression="Pro_Name" /> <asp:BoundField DataField="Pro_Price" HeaderText="售价" SortExpression="Pro_Price" DataFormatString="{0:f2}"/> <asp:TemplateField HeaderText="数量"> <ItemTemplate> <asp:Label ID="Num" runat="server" Text="1"></asp:Label> </ItemTemplate>Quote] 在模板里这样用,无法获得Label Control lbl = this.gridview1.Items[this.gridview1.SelectedIndex].FindControl("Label1");Label lbl1 = (Label)lbl; gridvie微软都没怎么去推他了,为啥还用这个,不用datagridview来取代? 不好意思,看成DataGrid了,那就这样GridView1.Columns[i].FindControl("CheckBox1"); 或者Control lbl = this.GridView1.Rows[this.GridView1.SelectedIndex].FindControl("Label1"); Label lbl1 = (Label)lbl; 在RowDeleting事件中string Num = ((Label)(gvSelect.Rows[e.RowIndex].Cells[3].FindControl("Num"))).Text.ToString().Trim();我看你打前台代码好像是在第3列 for (int i = 0; i < GridView1.Rows.Count; i++) { string lbl1= ((Label)this.GridView1.Rows[i].FindControl("Label1")).Text.Trim();自己看想取第几行的Label值 Label lbl = (Label )this.gvSelect.FindControl("Num");if(lbl !=null){int a =Convert.ToInt32(lbl.text);} GridView1.Rows[this.GridView1.SelectedIndex].FindControl("Label1");````` URL自动编码后找不到页面 急 急 急 急 GridView 高手进,如何 在GridView 上 实现 数据库的记录增加, GridView1 日期字段问题? 图片显示问题 GridView如何动态生成表头? 请教高手关于远程获取数据(小偷程序) 我在新建web项目的时候遇到这个问题"web服务器运行的不是asp.net1.1版本" ASP.NET ORACLE 连接问题(菜鸟级) (高手请进100)正则表达式的问题! 如何选定datagrid的某一行并变色后,取出选定行的某一列的值. 水晶报表合并列,画下线问题 combox已绑定,怎么通过ValueMember找到对应的哪项?求解
大写
[/ <asp:GridView ID="gvSelect" runat="server" AutoGenerateColumns="False"
DataKeyNames="Pro_Id" onrowdeleting="gvSelect_RowDeleting"
onrowdatabound="gvSelect_RowDataBound">
<Columns>
<asp:BoundField DataField="Pro_Id" HeaderText="产品编号" InsertVisible="False"
ReadOnly="True" SortExpression="Pro_Id" />
<asp:BoundField DataField="Pro_Name" HeaderText="已点菜单"
SortExpression="Pro_Name" />
<asp:BoundField DataField="Pro_Price" HeaderText="售价"
SortExpression="Pro_Price" DataFormatString="{0:f2}"/>
<asp:TemplateField HeaderText="数量">
<ItemTemplate>
<asp:Label ID="Num" runat="server" Text="1"></asp:Label>
</ItemTemplate>Quote]
Control lbl = this.gridview1.Items[this.gridview1.SelectedIndex].FindControl("Label1");
Label lbl1 = (Label)lbl;
GridView1.Columns[i].FindControl("CheckBox1");
Control lbl = this.GridView1.Rows[this.GridView1.SelectedIndex].FindControl("Label1");
Label lbl1 = (Label)lbl;
{
string lbl1= ((Label)this.GridView1.Rows[i].FindControl("Label1")).Text.Trim();自己看想取第几行的Label值
if(lbl !=null)
{
int a =Convert.ToInt32(lbl.text);
}