Access GridView Data Inside a Repeater Control |
|
Answered By
Moderator1
on
2/27/2010 10:17:18 PM |
|
|
|
|
Hi,
Its simple to access a gridview inside repeater. Follow the points below.
1. Repeater control must be bind at the page load or any event that initiates the Repeater Datasource.
2. GridView inside Repeater control must be bind at Repeater OnItemBound event.
2. Follow the sample code, to access the Repeater and its GridView control from a Submit Button, click event.
protected void Button1_Click(object sender, EventArgs e)
{
foreach (RepeaterItem repeaterItem in Repeater1.Items)
{
GridView GridView1 = (GridView)repeaterItem.FindControl("GridView1");
foreach (GridViewRow gvr in GridView1.Rows)
{
Response.Write(GridView1.ClientID + " - " + gvr.Cells[1].Text + "<br/>");
}
}
} |
|
|
|
Accessing Gridview data which is present inside a repeater |
|
Answered By
M Rakesh Jain
on
3/1/2010 2:21:34 AM |
|
|
|
|
Hi,
Thanks for your reply. I am able to access the rows of the grid view. But the problem
is that my repeater returns three rows. So there are three grid views generated inside my repeater. So i am able to access only the last gridview. Can you please help me on how to access all my gridviews ? |
|
|
|
Identify GridView in Repeater Control |
|
Answered By
Moderator1
on
3/1/2010 7:29:51 AM |
|
|
|
|
|
You need to identify which gridview data you are going to access. This can be achieved by placing a CheckBox control for every gridview, then use the GridView data for which checkbox is selected. |
|
|
|