We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Accessing control in current row

Thread ID:

Created:

Updated:

Platform:

Replies:

84527 Jul 1,2009 03:29 AM Jul 6,2009 01:52 AM ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
Administrator [Syncfusion]
Asked On July 1, 2009 03:29 AM


Lets say a user selected a row and entered edit mode.
A dropdown was loaded with certain values and a certain value was selected, now i would like to get to another dropdown in the same row and fill it with data.
In asp.net GridView it was something like this:

this.GridView1.Rows[this.GridView1.EditIndex].FindControl("someContorlId") as DropDownList

Rekha P [Syncfusion]
Replied On July 6, 2009 01:52 AM

Hi Eran,

Thank you for your interest in Syncfusion Products.

The embedded controls (EditItemTemplate) in a Grid row can be accessed by iterating through Grid top level row. Please refer a code snippet below to achieve this using DataSourceControlRowUpdating event.

void GridGroupingControl1_DataSourceControlRowUpdating(object sender, GridDataSourceControlRowUpdateEventArgs e)
{
Label1.Text = "";

DropDownList dropdown = null;
foreach (TableRow row in this.GridGroupingControl1.TopLevelTable.Rows)
{
if (row is GridRow)
{
GridRow gridRow = row as GridRow;

if (gridRow.Record != null)
{
foreach (GridCell gridCell in gridRow.Cells)
{
if (gridCell.ColumnDescriptor.Name == "Country")
{
foreach (Control cntl in gridCell.Controls[0].Controls)
{
if (cntl is DropDownList)
{
dropdown = cntl as DropDownList;
GridCellTemplated grid = (GridCellTemplated)dropdown.Parent.Parent;
GridRow gridrow1 = grid.Row;

Label1.Text += gridrow1.Record.GetValue("EmployeeID") + "--" + gridrow1.Record.GetValue("FirstName") + "--" + dropdown.SelectedItem.Text + "
";
gridRow.Record.SetValue("Country", dropdown.SelectedItem.Text);
}
}
}
}
}
}
}
}


The steps followed here are,
- Get the TableRow in the TopLevelTable
- Check if that Row is GridRow if so Iterate the Gridcells
- Find the TemplatedControl and the value.

Refer a sample illustrating the above.
http://files.syncfusion.com/support/GGC.Web/7.2.0.20/F82642_1/Sample.zip

Thanks,
Rekha

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;