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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

119141 May 13,2015 11:59 AM UTC May 18,2015 01:10 PM UTC ASP.NET MVC (Classic) 3
loading
Tags: Grid
Shwe
Asked On May 13, 2015 11:59 AM UTC

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

Kavitha Narayanan [Syncfusion]
Replied On 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.


Shwe
Replied On 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

Kavitha Narayanan [Syncfusion]
Replied On 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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;