Barış Velioğlu
Barış Velioğlu

Reputation: 5817

How to find selected row and column index together in Repeater on .NET

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,

Upvotes: 0

Views: 4712

Answers (3)

dave
dave

Reputation: 1550

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

Upvotes: 0

Hasan Fahim
Hasan Fahim

Reputation: 3885

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.

Upvotes: 1

Pit Digger
Pit Digger

Reputation: 9780

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.
}

Upvotes: 0

Related Questions