Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Frds,
I have Combo box inside datagridView...While Form load itself i am loading the combo box values...By below codes...I need to add "SELECT" to the combo box...and "SELECT" should display in the combo box first...How to do it.


datatable dt=datatable_value();
if (dt.Rows.Count > 0)
{
datagrid_Column1.DataSource = dt.DefaultView;
datagrid_Column1.DisplayMember = "Company_Name";
datagrid_Column1.ValueMember = "Company__Id";
}
Posted
Updated 19-Jul-12 20:51pm
v2


[^]checkout this link
 
Share this answer
 
Comments
itsureshuk 20-Jul-12 2:22am    
in normal form combo box shows that "SELECT" first after loaded...
but when Combo box in datagridview not showing the value "SELECT"...After selecting Combo box only it showing "SELECT" inside it...
Your question words confuses on what you are working on: Pageload says ASP.NET but tag, combobox, datagridview words says winforms!
Code you shared is of Grid!
:doh:


1. Easy way: Handle at DB level in query itself!
example query for data in combobox:
SQL
SELECT cbValue, cbText FROM myTable
UNION
SELECT '0' as cbValue, 'Select combobox' as cbText
ORDER BY cbValue


2. Other way: Add the select to the datatable retrieved and then bind it to the combobox. Use Index '0' to add the select to show it at the top.
 
Share this answer
 
Comments
itsureshuk 20-Jul-12 2:51am    
Form Load :Windows Application..."SELECT" is Added to combo box...but not able to see that "SELECT"...After clicking combo box only it shows that "SELECT"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900