如何在 .NET 上的 Repeater 中一起查找选定的行和列索引

发布于 2024-11-14 16:35:06 字数 124 浏览 3 评论 0原文

我有一个中继器组件来显示数据。我可以使用 Repeater1.Items[e.Item.ItemIndex].ItemIndex.ToString() 获取行索引,但它只给我选定的行。我怎样才能找到列索引?

提前致谢,

I have a repeater component to show data. I can get row index by using Repeater1.Items[e.Item.ItemIndex].ItemIndex.ToString() but it gives me just the selected row. How can I find also the column index ?

Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

溺孤伤于心 2024-11-21 16:35:06

Repeater 中没有行索引和列索引。只需使用 itemindex 就可以知道:

e.Item.ItemIndex

您不需要执行 Repeater1.Items[e.Item.ItemIndex].ItemIndex。

Repeater 控件用于显示绑定到该控件的重复项目列表。所以没有行或列。

There is no row and column index in repeater. Just itemindex which can be known using:

e.Item.ItemIndex

You don't need to do Repeater1.Items[e.Item.ItemIndex].ItemIndex.

The Repeater control is used to display a repeated list of items that are bound to the control. So there is no row or column.

扮仙女 2024-11-21 16:35:06

为了获取对转发器中控件的引用,我使用 FindControl(),它获取分配给 id 属性的控件的名称。

Dim EmployeeRepeater as Repeater = CType(Me.Form.FindControl("EmployeeRepeater")
Dim EmployeeRepeaterItem as RepeaterItem
Dim EmployeeName as Textbox

For Each EmployeeRepeaterItem In EmployeeRepeater.Items
    Employeename = CType(EmployeeRepeaterItem.FindControl("EmployeenNameTextBox")
    'do something here with Employee Name
Next

To get a reference to a control within a repeater I use FindControl() which takes the name of the control that was assigned to the id attribute.

Dim EmployeeRepeater as Repeater = CType(Me.Form.FindControl("EmployeeRepeater")
Dim EmployeeRepeaterItem as RepeaterItem
Dim EmployeeName as Textbox

For Each EmployeeRepeaterItem In EmployeeRepeater.Items
    Employeename = CType(EmployeeRepeaterItem.FindControl("EmployeenNameTextBox")
    'do something here with Employee Name
Next
桜花祭 2024-11-21 16:35:06
Button btn = sender as Button;
if (btn != null)
{
    RepeaterItem ri = btn.NamingContainer as RepeaterItem;
    if (ri != null)
        // use ri here as you see fit...  ri is a pointer to the item where the button was clicked.
}
Button btn = sender as Button;
if (btn != null)
{
    RepeaterItem ri = btn.NamingContainer as RepeaterItem;
    if (ri != null)
        // use ri here as you see fit...  ri is a pointer to the item where the button was clicked.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文