Connecting Tech Pros Worldwide Forums | Help | Site Map

DataGridView Combobox Column Problem

Newbie
 
Join Date: Sep 2008
Posts: 3
#1: Sep 22 '08
H,
At this moment my problem is how to make suplier combobox has different list in every row. I want suplier lists that related with a certain product instead of providing all the supliers.
Let say "product A" only has "Suplier B", "Suplier D" and "Suplier E",
"Product B" only has "Suplier A", "Suplier C", and
"Product C" only has "Suplier B", "Suplier D".
I can provide store procedure for this, but I don't know how to put this different datas in datagridviewcomboboxcolumn.

regards
Bhavani

Newbie
 
Join Date: Sep 2008
Posts: 17
#2: Sep 22 '08

re: DataGridView Combobox Column Problem


I think you can use item template to show combobox in grid. in rowbound event of grid find that combobox control of each row and call sp or query collect the values for combobox and bind that combobox with DataTextField & DataValueField.

May be you can use procedure as given below

protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{

DropdownList ddl= ((DropdownList )e.Row.FindControl("controlname"));
//Here you can write actual code
//Call sql query to retrive dropdown values individually
//Bind that ds/dt column values to ddl

ddl.DataTextField = " Column1";
ddl.DataValueField = "column2";
ddl.datasource = ds/dt;
ddl.databind();

}}
Reply