- Home
- Forum
- ASP.NET MVC (Classic)
- how to bind data and "selected index changed" event fire inside the inline form template of syncfusion grid grouping control
how to bind data and "selected index changed" event fire inside the inline form template of syncfusion grid grouping control
Query 1:Data bind into dropdown list
we would like to let you know that, we have bind the data source of dropdownlist in OnDataBinding event ,which has been mensioned in the name of CityTB_Load.
Please refer to the code snippets:
[C#]
public void DataBinding (object sender, EventArgs e)
{
DropDownList obj = sender as DropDownList;
GridFormEditCell cell = obj.Parent as GridFormEditCell; // get formeditcell
if (cell.CurrentRecord.GetValue("Country").ToString() == "France")
obj.DataSource = new List<string> { "Uk", "US" }; // Assign datasource based on record value
else
obj.DataSource = new List<string> { "Spain", "canada", "Germany" };
}
Query2:Selectedindexchanged event:
We have bind Selectedindexchanged and databinding event. Please refer to the code snippets below:
[CS]
protected void SelectedIndexChanged (object sender, EventArgs e)
{
// event
}
[aspx]
<asp:DropDownList ID="CityTB" AutoPostBack="true" OnDataBinding=" DataBinding " runat="server" OnSelectedIndexChanged=" SelectedIndexChanged " EnableViewState="true"></asp:DropDownList> For your reference , we have attached the sample. Sample: sample.zip
Please let us know if you need any further assistance.
Regards,
Kavitha.
Thank you so much for your reply. I tried this sample and it is working fine. When I tried "editable dropdown list" control instead of using "asp:dropdownlist" inside inlineform mode template of grid grouping control, "ddlCode_SelectedIndexChanged" event is not fired. And the data from "ddlName" is gone if I choose data from ddlCode. Please kindly help to advise.
<editable:EditableDropDownList ID="ddlCode" AutoPostBack="true" runat="server"
DataTextField="Code" DataValueField="Code"
Text='<%#GetFieldValue("Code", Container)%>' OnDataBinding="DataBinding"
OnSelectedIndexChanged="ddlCode_SelectedIndexChanged"
EnableViewState="true" >
<asp:ListItem> </asp:ListItem>
</editable:EditableDropDownList>
<editable:EditableDropDownList ID="ddlName" runat="server"
DataTextField="Name" DataValueField="Name"
Text='<%#GetFieldValue("Name", Container)%>' >
<asp:ListItem></asp:ListItem>
</editable:EditableDropDownList>
Thanks and Regards,
Shwe
Hi
Shwe,
We would like to let
know that, your requirement can be achieved with editable dropdown list. We have
bound the DataTextField and DataValueField properties in the databound event. Now the SelectedIndexChanged event
triggered.
Please refer the below code
snippets for Dropdownlist.
[aspx]
<editable:EditableDropDownList
ID="CityTB"
AutoPostBack="true"
runat="server"
OnDataBound="databound"
Text='<%#GetFieldValue("Country",
Container)%>'
OnDataBinding="databinding"
OnSelectedIndexChanged="SelectedIndexChanged"
EnableViewState="true">
</editable:EditableDropDownList>
[CS]
protected
void
databound(object
sender, EventArgs
e)
{
DropDownList
obj = sender as
DropDownList;
obj.DataTextField = "City";//set
DataTextField property
obj.DataValueField = "City";//set
DataValueField Property
}
AS for your reference, we have
prepared a sample and video demonstration. Please
download from the below link.
Sample:sample.zip
Sample Video:video.zip
Please let us know if you need any further assistance.
Regards,
Kavitha N.
- 3 Replies
- 2 Participants
-
SH Shwe
- May 13, 2015 11:59 AM UTC
- May 18, 2015 01:10 PM UTC