8 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 24 Sep 2012, 09:56 AM
Hi Swapnil,
Try the following code to achieve your scenario.
C#:
Thanks,
Princy.
Try the following code to achieve your scenario.
C#:
protected
void
Page_Load(
object
sender, EventArgs e)
{
SqlDataAdapter adapter =
new
SqlDataAdapter(
"SELECT EmployeeID, FirstName FROM Employees"
, con);
DataTable dt =
new
DataTable();
adapter.Fill(dt);
rcb_Users.DataTextField =
"FirstName"
;
rcb_Users.DataValueField =
"FirstName"
;
rcb_Users.DataSource = dt;
rcb_Users.DataBind();
}
protected
void
rcb_Users_DataBound(
object
sender, EventArgs e)
{
var combo = (RadComboBox)sender;
combo.Items.Insert(0,
new
RadComboBoxItem(
"Select"
,
string
.Empty));
}
Thanks,
Princy.
0

Swapnil
Top achievements
Rank 1
answered on 24 Sep 2012, 10:11 AM
Getting Error at the line:
Error:
The type or namespace name 'RadComboBoxItem' could not be found (are you missing a using directive or an assembly reference?)
Thanks Princy.
var combo = (RadComboBox)sender;
Error:
The type or namespace name 'RadComboBoxItem' could not be found (are you missing a using directive or an assembly reference?)
Thanks Princy.
0

Princy
Top achievements
Rank 2
answered on 25 Sep 2012, 04:25 AM
Hi Swapnil,
Please make sure that you adding the reference Telerik.Web.UI as follows.
C#:
Thanks,
Princy.
Please make sure that you adding the reference Telerik.Web.UI as follows.
C#:
using
Telerik.Web.UI;
Thanks,
Princy.
0

Swapnil
Top achievements
Rank 1
answered on 25 Sep 2012, 04:32 AM
Yes i have that namespace as well as that dll in bin folder of project,
I have added the element "Select" by using the property EmptyMessage="Select" and its working
just want to know is it correct?
Thanks
I have added the element "Select" by using the property EmptyMessage="Select" and its working
just want to know is it correct?
Thanks
0

Princy
Top achievements
Rank 2
answered on 26 Sep 2012, 05:09 AM
Hi Swapnil,
You can use EmptyMessage="Select" if you doesn't want select as the first item. And the text will go when the control get focused or any item is selected.
Hope this helps.
Thanks,
Princy.
You can use EmptyMessage="Select" if you doesn't want select as the first item. And the text will go when the control get focused or any item is selected.
Hope this helps.
Thanks,
Princy.
0

Swapnil
Top achievements
Rank 1
answered on 26 Sep 2012, 05:13 AM
select remains at first position because i have added other from database using property AppendDataBoundItems="true" and works correctely,
so can i use it further or it will create any problem.
Thanks
so can i use it further or it will create any problem.
Thanks
0
Accepted

Princy
Top achievements
Rank 2
answered on 27 Sep 2012, 04:31 AM
Hi,
If you add select as an empty message you don't need to set AppendDataBoundItems="true". The empty message will be shown as text when nothing is selected in the RadCombobox. Here Select is not a RadCombobox item. But it will not create any problem. And if you need Select as a RadCombobox item you can add it as follows.
ASPX:
Hope this helps.
Thanks,
Princy.
If you add select as an empty message you don't need to set AppendDataBoundItems="true". The empty message will be shown as text when nothing is selected in the RadCombobox. Here Select is not a RadCombobox item. But it will not create any problem. And if you need Select as a RadCombobox item you can add it as follows.
ASPX:
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
Width
=
"220px"
DataTextField
=
"name"
DataValueField
=
"name"
DataSourceID
=
"SqlDataSource1"
AppendDataBoundItems
=
"true"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"Select"
/>
</
Items
>
</
telerik:RadComboBox
>
Hope this helps.
Thanks,
Princy.
0

Swapnil
Top achievements
Rank 1
answered on 27 Sep 2012, 04:45 AM
Thanks for the valuable reply
it helps me,
Thanks
it helps me,
Thanks