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. Image for the cookie policy date
close icon

How to get selected value from EditItemTemplate-Dropdown?

Hi

WhWe have added a dropdown dynamically as in the code below. How do we get the value the user has selected in the drop down when the chenges are saved?

protected void GridControl_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (e.TableCellIdentity.Column.Name == ChecklistItemTableColumns.DepartmentID)
{
DropDownList departmentDropDown = new DropDownList();
departmentDropDown.ID = "m_DepartmentDropDown" + checklistItemID.ToString();
departmentDropDown.DataSource = GetDepartmentDataTable();
departmentDropDown.DataTextField = Department_LVTableColumns.DepartmentName;
departmentDropDown.DataValueField = Department_LVTableColumns.DepartmentID;
departmentDropDown.DataBind();
departmentDropDown.SelectedValue = e.Style.CellValue.ToString();
departmentDropDown.AutoPostBack = false;

TemplateClass editItemTemplate = new TemplateClass(departmentDropDown);
e.TableCellIdentity.Column.EditItemTemplate = editItemTemplate;
}


}


1 Reply

JA Janagan Syncfusion Team April 10, 2008 05:30 AM UTC

Hi Najir,

Thanks for your interest in Syncfusion products.

You can retrieve the values of the dropdown list in edit mode, by the following code below:



protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
Record rd = GridGroupingControl1.Table.CurrentRecord;

rd.SetValue("City", ddl.SelectedItem.Value);

}



Please refer the sample in the link below which illustrates the above:

http://www.syncfusion.com/support/user/uploads/dropdown_fd5cf997.zip

Please try running the sample and let me know if this helps.

Regards,
Janagan.





Loader.
Live Chat Icon For mobile
Up arrow icon