Hi Ruslan,
1.How to access the currently selected row's child controls.The embedded child controls (EditItemTemplate) 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.
2.Is there a way to "tell" the grid to take the SelectedValue from a dropdown and put it in a certain cell of the underlying datasource entry and to put the SelectedText in another cell of the underlying datasource entry.This can achieved through DataSourceControlRowUpdating event by getting New values of items that ready to be updated. The custom controls value can be accessed using the above code snippet.
3.I need the grid to add a new row via certain rulesThe AddNewRecords can be monitored using DataSourceControlRowAdding where you can access the currenly inserting records and customizing it.
void GridGroupingControl1_DataSourceControlRowAdding(object sender, GridDataSourceControlRowAddingEventArgs e)
{
//e.NewValues[0]
//you can access the newly inserted records through e.NewValues[0] with the corresponding index numbers.
}
AddNewRecords can also be checked by its type of elements using DisplayKind as AddNewRecord.
void GridGroupingControl1_CurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
if (e.Action == CurrentRecordAction.BeginEditComplete || e.Action == CurrentRecordAction.EnterRecordComplete
&& e.Record != null
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
//customize values for AddNewRecord
}
}
Refer a sample illustrating the above queries.
http://files.syncfusion.com/support/GGC.Web/7.2.0.20/F82642_1/Sample.zip4.I am having some perfomance issues during design time.We would like to suggest you to install VS2008 SP1.
http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=enand the Javascript intellisense patch.
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspxWe appreciate your patience and please let us know if you have any other concerns.
Thanks,
Rekha