DataGridView Combobox Column Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bhavanimikkilineni
    New Member
    • Sep 2008
    • 3

    DataGridView Combobox Column Problem

    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 datagridviewcom boboxcolumn.

    regards
    Bhavani
  • adityakoppolu
    New Member
    • Sep 2008
    • 17

    #2
    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_RowDa taBound(object sender, GridViewRowEven tArgs e)
    {

    if (e.Row.RowType == DataControlRowT ype.DataRow)
    {

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

    ddl.DataTextFie ld = " Column1";
    ddl.DataValueFi eld = "column2";
    ddl.datasource = ds/dt;
    ddl.databind();

    }}

    Comment

    Working...