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

how to bind data and "selected index changed" event fire inside the inline form template of syncfusion grid grouping control

Hi,
    I have a syncfusion grid grouping control using inline form mode template. I would like to bind data into dropdown list which is inside inline form template programmatically when I click the grid row and open inline form. And I also want to fire "selected index changed" event. Please kindly let me know how to bind data and "selected index changed" event fire.

Thanks and Regards,
Shwe

3 Replies

KN Kavitha Narayanan Syncfusion Team May 14, 2015 01:21 PM UTC

Hi Shwe,

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.



SH Shwe May 16, 2015 12:02 PM UTC

Hi 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


KN Kavitha Narayanan Syncfusion Team May 18, 2015 01:10 PM UTC

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.


Loader.
Live Chat Icon For mobile
Up arrow icon