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

GridDropDown is not displaying items in Grid

4 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
etu
Top achievements
Rank 1
etu asked on 22 Aug 2008, 07:24 AM
Hi,
 
I have GridDropDownColumn in RadGrid.In edit mode, i can select items from the GridDropDownColumn but when i click insert button, no items are shown in GridDropDownColumn in RadGrid.Can you help me?

Note : I am not using DataSource, i am using datatable in code to fill grid and dropdown.





In Edit Mode
Inserted Mode

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Aug 2008, 08:29 AM
Hi,

How do you bind your ComboBox? It would be better if you could send the code that you use.

Thanks
Princy.
0
etu
Top achievements
Rank 1
answered on 22 Aug 2008, 08:52 AM
here my code and aspx file.
codes

I create a datatable which may have some invalid columns.
I bind datatable to RadGrid.On item databound i fill dropdown.I am new user of Radcontrols.If you see any major error in my code , i am sorry :)

0
etu
Top achievements
Rank 1
answered on 22 Aug 2008, 08:53 AM
on aspx file , Although i tried datavaluefield,datatextfield,datafield properties in GridDropDownColumn, all the properties didnt work.
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Aug 2008, 10:55 AM
Hello Etu,

Your codes were not viewble. Anyways, you can bind your GridDropDownColumn in Edit/InsertMode as shown in the code below.
cs:
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem ititem = (GridEditableItem)e.Item; 
            GridEditManager editMan = ititem.EditManager; 
            GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("ComboBox")); 
 
            string ConnectionString = "Data Source=INC135; Initial Catalog=MyDataBase;User ID=sa; Password=softinc"
            SqlConnection conn = new SqlConnection(ConnectionString); 
            SqlCommand cmdCustomers = new SqlCommand("SELECT Age FROM Reservation", conn); 
            cmdCustomers.CommandType = CommandType.Text; 
            conn.Open(); 
            SqlDataReader reader = cmdCustomers.ExecuteReader(); 
            editor.DataSource = reader
            editor.DataTextField = "Age";            
            editor.DataBind(); 
            conn.Close();             
        } 
    } 

For more information on Customizing a GridDropDownColumn refer to this link.

Princy.


Tags
Grid
Asked by
etu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
etu
Top achievements
Rank 1
Share this question
or