Wednesday, March 28, 2012

Accessing SelectedIndex of Datagrid inside a bound Accordion Control

I have a bound Accordion Control with its Content Template containing a gridview. Each Gridview is populated on the Accordion ItemDataBound.

The Gridview containes a set of bound checkboxes with autopostback set to true.

When a checkbox is clicked i need to find the selectedindex of the row in the gridview in question. I'm trying to retreive the selected index from within the form load event.

Any ideas?

Just to let you know, if you have your checkbox inside the GridView, you have to find the control within the GridView first and then see what is the selected value or index.

CheckBox myCheckBox = (CheckBox) GridView1.FindControl("myCheckBox1");

int i = myCheckBox.SelectedIndex;

Just one more thing, Enable Tracing for your page Trace="true" in the <%@.Page Language=... so you can see what is the name for your control. Because if you are using master page the names would be auto generated with a prefix.

Hope this would be any help to you.

Regards,
Mehdi


Just to let you know, if you have your checkbox inside the GridView, you have to find the control within the GridView first and then see what is the selected value or index.

CheckBox myCheckBox = (CheckBox) GridView1.FindControl("myCheckBox1");

int i = myCheckBox.SelectedIndex;

Just one more thing, Enable Tracing for your page Trace="true" in the <%@.Page Language=... so you can see what is the name for your control. Because if you are using master page the names would be auto generated with a prefix.

Hope this would be any help to you.

Regards,
Mehdi


Thanks for the reply.

It doesn't realy help as firstly I need to find the gridview within the accordion control, then find the datakey of the row (checkbox) that's been clicked on.

I'm not sure how to index the accordion control as it's bound and doesn't use the panes collection?

No comments:

Post a Comment