Hi Santhosh,
Thanks for your interest in Syncfusion products.
Query #1"I am trying to figure out how to dynamically add a record with 3 columns, one of which is a DropDownList"
Your requirement can be achieved by adding the record to grid in button click event using AddNewRecord dynamically. The value for the record is set using SetValue() method.DropDownList can be added as ItemTemplate in QueryCellStyleInfo. Please refer the below code snippet.
[Code behind - C#]
void GridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "Category")
{// ItemTemplate Creation.
DropDownList ddl = new DropDownList();
string[] controls = { "Level1", "Level2", "Level3" };
ddl.DataSource = controls;
ddl.DataBind();
ddl.SelectedValue = Convert.ToString(e.Style.CellValue);
TemplateClass temp = new TemplateClass(ddl);
e.TableCellIdentity.Column.ItemTemplate = temp;
}
}
}
//Add button click event for adding record
protected void RecordAdd(object sender, EventArgs e)
{
this.GridGroupingControl1.CurrentTable.AddNewRecord.BeginEdit();
this.GridGroupingControl1.CurrentTable.AddNewRecord.SetValue("ID", 2);
this.GridGroupingControl1.CurrentTable.AddNewRecord.SetValue("Name", "Company2");
this.GridGroupingControl1.CurrentTable.AddNewRecord.SetValue("Category", "Level2");
this.GridGroupingControl1.CurrentTable.AddNewRecord.EndEdit();
}
For your convenience, we have created sample and the same can be downloaded from the following link.
Forum44425044.zipPlease let me know if you have any other questions or concerns.
Regards,
Sridhar.N