This is a migrated thread and some comments may be shown as answers.

RadCombo Box binding in edit pop-up ..

1 Answer 58 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
S
Top achievements
Rank 1
S asked on 20 Dec 2011, 09:35 PM
Hi,

I have a scenario where I display huge data and edit them using pop-up..

Some of my fields need to be comboboxes...where data has to be binded to tht particulat value for that resource..

I have a table employee...which has status (active,inactive)...but I need to bind this data from a look up table..
   EmploymentStatus:    <telerik:RadComboBox ID="ddlStatus" runat="server"    AppendDataBoundItems="true"                                         AllowCustomText="true" > </telerik:RadComboBox>

I have tried the below code to bind the values:but it didn't wok..getting null value in to the list object..

 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            GridEditableItem item = e.Item as GridEditableItem;
          RadComboBox list = item.FindControl("ddlStatus") as RadComboBox;
            SqlDataReader ddDR = null;
            myCommand.CommandText = "SELECT  [Name],[value]  FROM [Table1] where Name='Status'";
            myConnection = new SqlConnection(myConnectionstr);
            myConnection.Open();
            myCommand.CommandType = CommandType.Text;
            myCommand.Connection = myConnection;
            ddDR = myCommand.ExecuteReader();
            list.DataSource = ddDR;
            list.DataTextField = "Name";
            list.DataValueField = "Value";
            list.DataBind();


            ddDR.Dispose();
            myCommand.Dispose();
            myConnection.Dispose();
        }

    }

Can you please let me know how do I bind the data and also get the correct values when i click edit and empty value when I click insert...Will be of gr8 help..

Please advise..
thanks


                 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar Terziev
Telerik team
answered on 23 Dec 2011, 01:21 PM
Hi,

Please move your logic for the RadComboBox's population in the ItemDataBound event handler function of the RadGrid. Here  you could find a help article demonstrating such approach.

Regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ComboBox
Asked by
S
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or