如何从列表视图访问输入项。 [英] How do I access input item from listview.

查看:58
本文介绍了如何从列表视图访问输入项。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

我不明白我怎么能以编程方式访问listview中的项目。我的listview中有文本框:

 <   asp :ListView     ID   =  ListView1    ...     EnableViewState   =  false    

runat = server >
... < EditItemTemplate >
< tr > ...

< td >
< asp:TextBox runat = server OnTextChanged = Commenary_TextChanged id = Commenary / > < / td >
< td >





我需要从文本框中取出文本并将其保存在字符串变量中。我怎么能成功?



我尝试过:



我尝试在我的列表视图中找到它:



  var  item = ListView1.FindControl( 评论); 
string asd = item.ToString();





像这样:

 TextBox tmpControl =(TextBox)ListView1.FindControl( 评论); 
string xxx = tmpControl.Text.ToString();





我在两种情况都无效。

我也尝试将文本框更改为输入标签,但我也没有。

解决方案

有一个如何编辑a的示例listview并访问这里的控件



编辑,更新,在ListView控件中删除和插入 [ ^

Hi all .
I coudn't understand how i can acess item in listview programmatically . I have textbox in my listview:

  <asp:ListView ID="ListView1" ... EnableViewState="false" 

        runat="server"  >
... <EditItemTemplate>
            <tr> ...

 <td>
                    <asp:TextBox runat="server"  OnTextChanged="Commenary_TextChanged"   id="Commenary"/></td>
                     <td>



I need to take text from textbox and save it in string variable . How i can make it?

What I have tried:

I try to find it in my listview like this :

var item = ListView1.FindControl("Commentary");
string asd = item.ToString();



And like this:

TextBox tmpControl = (TextBox)ListView1.FindControl("Commentary");
string  xxx = tmpControl.Text.ToString();



I have null in both situarion.
Also i tried to change textbox to input tag, but i have nothing too.

解决方案

There is an example of how to edit a listview and access the controls here

Edit,Update,Delete and Insert in ListView Control[^]


这篇关于如何从列表视图访问输入项。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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