有人可以帮我吗 [英] can any one help me regarding for this

查看:75
本文介绍了有人可以帮我吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从网格视图获取价值
在网格视图中,我有模板字段,我想从label1检索值并在会话变量中分配此值

How to retreive value from grid view
in grid view i have template field and i want to retrieve value from label1 and assign this value in session variable

<asp:TemplateField>

                   <ItemTemplate>
                   <table>
                    <tr>
                       <td rowspan="4">&nbsp;</td>
                       <td><a href="offerdetails.aspx"  style="text-decoration: blink">
                           <asp:Label ID="Label1" runat="server" Text='<%# Bind("AdTitle") %>'></asp:Label></a></td>
                        <td>
                            &nbsp;</td>
                   </tr>

推荐答案

您必须使用FindControl.
You have to use FindControl.
Label lbl = gridview.Rows[index].FindControl("Label1") as Label;
Session["ssnLabelText"] = lbl.Text; 


您好
通过找到标签控件,您可以将标签的数据存储到会话中

Hi
By finding the label control you can store the data of the label to session

gridviewrow row=gridview1.rows[1] as gridviewrow;

 lable lbl=row.fincontrol("Label1");

Here the Label1 is the control in your gridveiw


在Gridview中的ItemTemplate 中的Label 位置使用FindControl .
Use FindControl for the Label place in ItemTemplate in a Gridview.

Label lbltxt=(Label)gridview.Rows[index].FindControl("Label1");
Response.Write(lbltxt.Text)


谢谢


这篇关于有人可以帮我吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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