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

Combobox not selecting items correctly

7 Answers 157 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
CBARS
Top achievements
Rank 2
CBARS asked on 20 Oct 2008, 09:43 AM
Hi,
Im having a problem with the telerik rad combobox.

i am dynamically creating the combobox and setting the combobox's datasource to a precreated datatable.
i am planning on using the item template to display more than one value in the combobox's items.
the combobox loads correctly but when i select an item and click off the combobox it select's the first item in the list.
i also cannot select the first item in the combobox,
and the TextChanged, SelectedIndexChanged, ItemsRequested events never fire

here is some code:

Page_Load
{
TableRow tblRow;
TableCell tblCell;
Telerik.Web.UI.RadComboBox cmbo;

tblCell = new TableCell();
cmbo = new Telerik.Web.UI.RadComboBox();
cmbo.ID = "cmbo1";
cmbo.ItemDataBound += new Telerik.Web.UI.RadComboBoxItemEventHandler(cmbo_ItemDataBound);
cmbo.SelectedIndexChanged += new Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventHandler(cmbo_SelectedIndexChange);
cmbo.ItemsRequested += new Telerik.Web.UI.RadComboBoxItemsRequestedEventHandler(cmbo_ItemsRequested);
cmbo.TextChanged += new EventHandler(cmbo_TextChanged);

cmbo.DataSource = ds.Tables[0];

cmbo.DataSource = ds.Tables[0];
cmbo.DataBind();
tblCell.Controls.Add(cmbo);
tblCell.ColumnSpan = 2;
tblRow.Cells.Add(tblCell);
tbl1.Rows.Add(tblRow);
}

private void cmbo_ItemDataBound(object o, Telerik.Web.UI.RadComboBoxItemEventArgs e)
{
            e.Item.Text = ((DataRowView)e.Item.DataItem)[1].ToString();
}


tblCell.Controls.Add(cmbo);
                                    tblCell.ColumnSpan = 2;
                                    tblRow.Cells.Add(tblCell);



any help would be appreciated,
Regards.


7 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 20 Oct 2008, 02:02 PM
Hi Cbars,

I suggest you set the AutoPostBack proeprty of RadComboBox to true.

for example:
cmbo.AutoPostBack = true.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CBARS
Top achievements
Rank 2
answered on 21 Oct 2008, 08:08 AM
Hi, thanks for your quick reply.
i tried setting the autopost property to true, but because i am creating the controls dynamically it gives me this error:
htmlfile: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.

and i still cant select the first item in the combobox.
Regards


0
Rosi
Telerik team
answered on 21 Oct 2008, 08:47 AM
Hi Cbars,

Please try attached latest internal build.This should helps.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CBARS
Top achievements
Rank 2
answered on 21 Oct 2008, 10:55 AM
Hi,
i replaced my telerik dlls with the ones you gave me and re-added the reference to it, but now it comes up with this error when the page loads:

Could not load file or assembly 'Telerik.Web.UI, Version=2008.2.826.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

thanks,
Regards.
0
Rosi
Telerik team
answered on 21 Oct 2008, 11:46 AM
Hi Cbars,

Perhaps you have an reference to the old version in the web.config file.

I suggest you update the reference in the web.config to match the version of the new assembly.

All the best,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CBARS
Top achievements
Rank 2
answered on 21 Oct 2008, 01:18 PM
Hi,
thanks i got the page to load now, i used the ones in the bin35 folder you gave me version: 2008.2.1020.35, but i still got the same problem of not being able to select the first item in the combo box. i tried with a bigger datatable to bind to the datasource but then as soon as i click off the combobox it goes back to the first item.

sorry for the trouble,
Thanks,
Regards,
0
CBARS
Top achievements
Rank 2
answered on 21 Oct 2008, 02:04 PM
Hi, i figured it out, i just set the datavaluefield to an id field

thanks for all your help.
regards,
Tags
ComboBox
Asked by
CBARS
Top achievements
Rank 2
Answers by
Rosi
Telerik team
CBARS
Top achievements
Rank 2
Share this question
or