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

Rad Combo Rebind

8 Answers 517 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 19 Jun 2012, 09:54 AM
Hi all,


How can i rebind my Rad Combo 


Regard's

Prassin

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jun 2012, 11:50 AM
Hi Prassin,

For Rebinding the RadComboBox try the DataBind() method of the RadComboBox as follows.

C#:
RadComboBox1.DataBind();

Hope this helps.

Thanks,
Shinu.
0
Prassin
Top achievements
Rank 1
answered on 19 Jun 2012, 11:52 AM
Hi shinu,

i have already did this functionality .. its not working that seems

Regards

Prassin
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2012, 08:43 AM
Hi,

Please elaborate your scenario with code so that I can replicate the issue.

Thanks,
Shinu
0
Prassin
Top achievements
Rank 1
answered on 20 Jun 2012, 09:03 AM
Hi Shinu,


i have one combo box. the visibility of this combo box depends up on a button click. if the state of the combo box is not visible that time i need to rebind the combo filed.. other wise the previous selected item is shown at when the combo state visible . so i need to avoid this problem.


thanks 
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2012, 09:29 AM
Hi Prassin,

Here is the code snippet that I tried and worked as expected at my end.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" ></telerik:RadComboBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" />

C#:
protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection(str);
        command = "SELECT EmployeeID, FirstName FROM Employees";
        ad = new SqlDataAdapter(command, con);
        DataTable dt = new DataTable();
        ad.Fill(dt);
        RadComboBox1.DataTextField = "FirstName";
        RadComboBox1.DataValueField = "FirstName";
        RadComboBox1.DataSource = dt;
        RadComboBox1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (RadComboBox1.Visible == false)
        {
            con = new SqlConnection(str);
            command = "SELECT EmployeeID, FirstName FROM Employees";
            ad = new SqlDataAdapter(command, con);
            DataTable dt = new DataTable();
            ad.Fill(dt);
            RadComboBox1.DataTextField = "FirstName";
            RadComboBox1.DataValueField = "FirstName";
            RadComboBox1.DataSource = dt;
            RadComboBox1.DataBind();
            RadComboBox1.Visible = true;
        }
        else
        {
            RadComboBox1.Visible = false;
        }
    }

Please provide your code if it doesn't helps.

Thanks,
Shinu.
0
Daniel
Top achievements
Rank 1
answered on 20 Mar 2014, 10:47 AM
how can I rebind when model binding (Selectmethod) is used? 

thx
0
Daniel
Top achievements
Rank 1
answered on 20 Mar 2014, 11:08 AM
second question

How can i set the selected item in RadComboBox when SelectMethod is fired after Page_PreRender?

thx
0
Shinu
Top achievements
Rank 2
answered on 20 Mar 2014, 12:28 PM
Hi Daniel,

As for your first question you can use the following code snippet to Rebind the RadComboBox.

C#:
RadComboBox1.DataSourceID = "ObjectDataSource1";
RadComboBox1.DataTextField = "OrderID";
RadComboBox1.DataValueField = "OrderID";
RadComboBox1.DataBind();

Please try the following code snippet to select an item of the RadComboBox.

RadComboBox1.FindItemByText("10310").Selected = true;

Thanks,
Shinu.
Tags
ComboBox
Asked by
Prassin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Prassin
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Share this question
or