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.
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.