This is a migrated thread and some comments may be shown as answers.

How to bind data to GridDropDownColumn

3 Answers 190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
suresh
Top achievements
Rank 1
suresh asked on 27 Feb 2012, 04:45 AM
Hi there,
I need to bind the listitems into the GridDropdownColumn in edit mode where my grid also bind data from DataTable.I have seen so many examples and all of them gave the solution with GridTemplateColumn..I cant understand is there is a only way for showing dropdownlist in edit mode????..If it is then what is the use of GridDropdownColumn and how can i bind list of items into it without using GridTemplateColumn..

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Feb 2012, 05:18 AM
Hello Suresh,

Try the following code.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
  GridEditableItem item = (GridEditableItem)e.Item;
  RadComboBox RadComboBox1 = (RadComboBox)item["UniqueName"].Controls[0];
  ArrayList list = new ArrayList();
  list.Add("item1");
  list.Add("item2");
  RadComboBox1.DataSource=list;
  RadComboBox1.DataBind();
 }
}

-Shinu.
0
suresh
Top achievements
Rank 1
answered on 27 Feb 2012, 09:33 AM
Thanks shinu.That solution bring me the correct path..But I have a problem to show the selected item from the Radcombobox to the Radgrid after update command. which means DropdownColumn shows the previous value that i bind on pageload..It never shows the radcombobox selected item after edit the column..
0
Shinu
Top achievements
Rank 2
answered on 08 Oct 2012, 09:18 AM
Hi,

Try the following code to show the selected value in dropdowncolumn.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
      GridDataItem item = (GridDataItem)e.Item;
      DataRowView row = (DataRowView)e.Item.DataItem;
      item["UniqueName"].Text = row["DataTextField"].ToString();
   }
}

Thanks,
Shinu.
Tags
Grid
Asked by
suresh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
suresh
Top achievements
Rank 1
Share this question
or