从GridView中的标签获取值 [英] Getting values from label in gridview

查看:86
本文介绍了从GridView中的标签获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我有网格,其中使用标签在每一列中显示值.
我如何获取该标签的值作为键(用户ID)以执行添加,删除,编辑
我尝试了

e.CommandArgument.ToString()

,但没有给出必需的结果

在此先感谢

解决方案

在这里使用简单的ans

((Label)gv.SelectedRow.FindControl("lblId")).Text


处理该标签在另一列中的值,并将该列的宽度设置为0,以使其不可见
并从隐藏的列中获取该值.希望这一技巧将有助于解决您的问题.然后获取找到的控件的Text属性.标签控件不是命令控件,不能设置命令参数.


hello friends,
I have grid, in which i have used label to display values in each column.
how can i get values of that label as key(userid) to perform add, delete, edit
I tried

e.CommandArgument.ToString()

, but not giving required reult

Thanks in advance

解决方案

Here the simple ans for it

((Label)gv.SelectedRow.FindControl("lblId")).Text


handle that label value in another column and set that column width=0 so it will not be visible
and get that value from the hidden column.Hope this trick will help to solve ur problem.


Get the Row, use FindControl method to find the specific label with the id. Then get the Text property of the found control. Label control is not a command control and can''t set the command argument.


这篇关于从GridView中的标签获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆