如何在C#中的gridview中获取标签ID [英] How to get label id inside the gridview in C#
本文介绍了如何在C#中的gridview中获取标签ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我已经在gridview中给了新标签..我已经在javascript中分配了此标签ID以获取值...
然后,在插入或更新gridview时,我需要在C#中获得此值..
所以我在C#中给了标签,如下所示
Hi all,
I have given new label inside the gridview..I have assign this label ID in javascript to get the value...
Then I need to get this value in C# when inserting or updating the gridview..
So I have given label in C# like shown below
Label labelimg = ((Label)row.FindControl("lblmenuimg"));
string imagepath = labelimg.Text;
当我运行此项目时,"labelimg.Text"显示为空值..
问候
vivek
When I run this project the "labelimg.Text" shows null value..
Regards
vivek
推荐答案
您都应该发布代码,并正确标记问题(这是ASP.NET问题).如果您使用javascript将某些内容插入页面,则我认为服务器看不到它.我认为您需要有一个隐藏字段,用于存储所插入内容的详细信息,以便在回发中阅读.
You should both post code, and tag your question properly ( it''s an ASP.NET question ). If you insert something in to a page using javascript, I don''t think the server can see it. I think you need to have a hidden field that you use to store the details of anything you inserted, to read it in a postback.
尝试这一步
Try This One
Label lbl = (Label)GridView1.Rows[rowindex].FindControl("Label1");
以及您想在何处使用标签值lbl.text
...
祝你好运
and where ever you want label value use lbl.text
...
good luck
这篇关于如何在C#中的gridview中获取标签ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文