.net中如何从后台获取repeater中的文本框的值

.net中如何从后台获取repeater中的文本框的值,第1张

foreach (RepeaterItem item in thisrptItems)

{

TextBox txt= itemFindControl("txtID") as TextBox ;

string str= txtText;

}

aspnet中获取repeater中的数据的方法是使用DataBinderEval循环获取。

Repeater 控件用于显示重复的项目列表,这些项目被限制在该控件。Repeater 控件可被绑定到数据库表、XML 文件或者其他项目列表。

以下的完整的读取Repeater的值的方法:

<%@ Import Namespace="SystemData" %>

<%@ Import Namespace="SystemDataSqlClient" %>

<html>

<script language="C#" runat="server">

void Page_Load(Object sender, EventArgs e)

{

// 创建连接到pubs数据库

// 访问本地的数据库

SqlConnection myConnection = new SqlConnection("server=localhost;" +

"database=pubs;Trusted_Connection=Yes");

// 使用select语句查询title表中的所有记录

SqlDataAdapter myCommand = new SqlDataAdapter("SELECT FROM" +

" Titles", myConnection);

// 创建并且填充结果集

DataSet ds = new DataSet();

myCommandFill(ds);

// 绑定数据到MyRepeater

MyRepeaterDataSource = ds;

MyRepeaterDataBind();

}

</script>

<%-- 循环读取 MyRepeater中的数据--%>

<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<ASP:Repeater id="MyRepeater" runat="server">

<HeaderTemplate>

<Table width="100%" style="font: 8pt verdana">

<tr style="background-color:DFA894">

<th>

Title

</th>

<th>

Title ID

</th>

<th>

Type

</th>

<th>

Publisher ID

</th>

<th>

Price

</th>

</tr>

</HeaderTemplate>

<ItemTemplate>

<tr style="background-color:FFECD8">

<td>

<%# DataBinderEval(ContainerDataItem, "title") %>

</td>

<td>

<%# DataBinderEval(ContainerDataItem,"title_id") %>

</td>

<td>

<%# DataBinderEval(ContainerDataItem, "type") %>

</td>

<td>

<%# DataBinderEval(ContainerDataItem, "pub_id") %>

</td>

<td>

<%# DataBinderEval(ContainerDataItem,

"price", "{0:c}") %>

</td>

</tr>

</ItemTemplate>

<FooterTemplate>

</Table>

</FooterTemplate>

</ASP:Repeater>

</body>

</html>

最简单的最好用的方法,放一个隐藏域(不知道什么是隐藏域的去百度搜一下),通过JS的点击事件,把值赋到隐藏域,后台取隐藏域的值即可,什么,你的不是网站是应用程序?好像应用程序中没有repeater吧,哈哈,应用程序中的DataGrid可以通过触发单击事件,在后台取 “在点击的这一行的里面查找你指定的文档框”即可。如果是网站也要在后台触发,也行,查找这一行的文本框的ID再取值。

以上就是关于.net中如何从后台获取repeater中的文本框的值全部的内容,包括:.net中如何从后台获取repeater中的文本框的值、asp.net中怎样获取repeater中的数据、repeater里面的onclick事件怎么样获取到文本框值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9474557.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存