Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 puting a comboBox in my datagrid

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-05-14 : 21:01:51
I have two tables tbl1 and tbl2. Tbl1 is the datasource of mydataGrid. Tbl1 has 4 columns (all with mapping names from Tbl1).

I want to add a combo box in the fifth column that has its values from Tbl2.

Is that possible and how pls. (i m developping a windows form application and not a web application)
Thanks

dfiala
Posting Yak Master

116 Posts

Posted - 2006-05-14 : 21:12:31
Yes.

Use a template column.

In the item template add a dropdownlist.

In the Item_DataBound event, bind the dropdown list to the second table.

Here's th basic idea.
http://www.odetocode.com/Articles/231.aspx

But instead of creating the dropdown list items manually, you'd bind the grid to the table.

Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-05-14 : 21:15:18
sorry I forgot to mention that i m making a windwos form application and not a web application thanks
Go to Top of Page

dfiala
Posting Yak Master

116 Posts

Posted - 2006-05-14 : 22:13:06
You did mention it, but since this is an ASP.NET forum it didn't register. :)

You can still do it. Likely easier in WinForms. Check this out...

http://www.codeproject.com/cs/miscctrl/RenDataGridComboBoxColumn.asp



Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-05-15 : 00:23:15
funny, thanks
Go to Top of Page
   

- Advertisement -