在一个asp.net中继服务器控件 [英] Server controls in an asp.net repeater

查看:81
本文介绍了在一个asp.net中继服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好像我已经撞上了墙在这里。我想要一些数据源绑定到一个asp.net中继器(当然,并不一定是一个中继器,但似乎这就是我想要的)。现在,这里的渔获:我还需要一个中继器内部的一些服务器控件更新数据(TextBox'es和按钮)

Seems like I've ran into a wall here. I want some datasource to be bound to an asp.net repeater (well, doesn't have to be a repeater, but it seems like that's what I want). Now, here's the catch: I also need some server-controls inside that repeater for updating the data (TextBox'es and buttons).

据我了解,这AINT真的有可能以一种有序的方式呢?我不能只是添加一个文本框ItemTemplate模板,然后在code-背后似乎后来把它拿来。至少不容易。是否有这样那样的问题?

To my understanding, this aint really possible to do in an orderly manner? I can't just add a textbox to the itemtemplate, and then fetch it later on in the code-behind it seems. At least not easily. Are there any known techniques for this kind of problem?

我不能使用GridView,因为需要将数据以某种方式进行格式化。

I can't use a gridview, since the data needs to be formatted in a certain way.

推荐答案

如果你不想使用一个ItemCommand和只想通过Repeater的项目收集循环,让你有一个保存按钮在底部页面,你可以做这样的:

If you don't want to use an ItemCommand and want to just loop through the Repeater's items collection, so you have one "save" button at the bottom of the page, you can do it like this:

foreach(RepeaterItem itm in MyRepeater.Items)
{
     TextBox t = (TextBox)(itm.FindControl("TextBox1"));
     // do something with it.

}

当然,你需要确保在ASPX的TextBox1中有=服务器属性。

Of course, you'll need to make sure that the TextBox1 in the ASPX has the Runat="Server" attribute.

这篇关于在一个asp.net中继服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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