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

Cant access the radComboBox objects on a form

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Goat_
Top achievements
Rank 1
Goat_ asked on 16 Apr 2013, 07:21 AM
Hi, im using C# and linq

I have to store the values of the selected items from my RadComboBoxes into a database.

I have a form with 15+ comboBoxes which get populated from the database on_load, i also have a "Save" button that should be saving  selectedValues of those boxes into another database. When i enter the "Click" event for my "Save" button i do not have access to any of the comboBox objects.
And when i say i do not have access to the object,i have a Box with the ID="cboAccount", i cannot call cboAccount.SelectedValue for example.

So i tried the following just to check if i could get access to the selected values
RadComboBox oops = new RadComboBox();
 
oops.ID = "cboAccount";
 
Response.Write("<script language='javascript'>alert('" + Server.HtmlEncode(oops.SelectedValue) + "')</script>");

but once the message displays the message is blank.

I already know how to insert data into a database with linq i just need to know how can i access the actual ComboBox Objects and the selected values so i can insert the data into the database.

thanx

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Apr 2013, 08:04 AM
Hi,

Unfortunately I cammot replicate the issue at my end. Here is the full code that I tried to get the selected value.
C#:
RadComboBox oops;
protected void Page_Load(object sender, EventArgs e)
{
        oops = new RadComboBox();
        oops.DataSourceID = "SqlDataSource2";
        oops.DataTextField = "OrderID";
        oops.DataValueField = "OrderID";
        oops.ID = "cboAccount";
        form1.Controls.Add(oops);
}
protected void Button2_Click(object sender, EventArgs e)
{
        string value = oops.SelectedValue.ToString();
}
Thanks,
Shinu.
Tags
Grid
Asked by
Goat_
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or