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

Binding a datasource in the Dropdowncolumn that is not in The Grids Datasource....

6 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erwin
Top achievements
Rank 1
Erwin asked on 02 Feb 2010, 12:25 PM
Hello Everyone!

I have a problem regarding the DropdownColumn of the grid.

I have a grid with an inline edit and add mode. I also have a Dropdowncolumn in my grid.

What i want is that when I a new item using inline adding of the grid, the Dropdownlist of the Dropdowncolumn should display Items that are not added in the grid.

In short, The Items that are in the grid (specifically in my dropdown column) should not be displayed in the DropDownList during Adding.

I have tried this link

http://www.telerik.com/help/aspnet-ajax/grdcustomizeconfiguregriddropdowncolumn.html

but If I change the datasource of the DropDownColumn, the grid data of my DropDownColumn will be replaced with the firts item in my dropdownlist during adding mode.

6 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 05 Feb 2010, 12:09 PM
Hello Erwin,

You could bind the GridDropDownColumn to the SqlDataSource and use a select query which get only distinct data from the database.  
Please review the below article on how to bind GridDropDownColumn to SqlDataSource:

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx

The other option is on RadGrid.ItemDataBound event to check if the grid is in insert mode and you could try to remove all Items from the dropdown list which already have been added to the grid accordingly.

I hope this helps.

All the best,
Radoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Nathan
Top achievements
Rank 1
answered on 05 Feb 2010, 02:35 PM
Radoslav,

Not to Hijack Erwins post but what triggers the ItemDataBound?  I have a dropdown menu and even if I am in editmode the itemdatabound is not being triggered. 
0
Radoslav
Telerik team
answered on 10 Feb 2010, 02:17 PM
Hi Nathan,

The ItemDataBound event is fired only when the grid binds to data. It is fired just after ItemCreated event. So you could create the controls in the ItemCreated event handler and bind them to data in the ItemDataBound (if that's needed).

More information about the ItemDataBound event you could find in the following online documentation article:

http://www.telerik.com/help/aspnet-ajax/telerik.web.ui-telerik.web.ui.radgrid-itemdatabound_ev.html

Additionally could you please send us a simple runnable application demonstrating the described issue. You could open a formal support ticket from your Telerik account and attach a ZIP file there. I will inspect the code and advise you further.

I hope this helps

Sincerely yours,
Radoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Erwin
Top achievements
Rank 1
answered on 15 Feb 2010, 11:17 AM
I follow some people's advice and solved the problem

I made my Dropdowncolumn to a template column with
Itemtemplate
    Label: with a value using DataBinder(datafield) from the datasource of the grid
EditItem
    Combobox: with the value of the items to be shown
                        filtered not to have items that are not in the grid.

and my problem was solved...

thanks for the replay
0
Sreekanth
Top achievements
Rank 1
answered on 16 Jan 2012, 01:56 PM
Hi,
I am currently working on the GridDrodown column where am unable to bind the data to the GridDrodown coulmn.
I dont want to use Template coulmn,can you please provide me a sample working project.

I have tried the below links,but these were not helpfull.

http://www.telerik.com/help/aspnet/grid/grdcustomizeconfiguregriddropdowncolumn.html

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx


Regards,
Sreekanth
0
Shinu
Top achievements
Rank 2
answered on 17 Jan 2012, 06:34 AM
Hello Sreekanth,

Try the following code.
C#:
protected void grid_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
   GridEditableItem item = (GridEditableItem)e.Item;
   DropDownList ddl = (DropDownList)item["UniqueName"].Controls[0];
   ddl.DataSourceID = "SqlDataSource1";
   ddl.DataTextField = "Id";
   ddl.DataValueField = "Id";
 }
}

-Shinu.
Tags
Grid
Asked by
Erwin
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Nathan
Top achievements
Rank 1
Erwin
Top achievements
Rank 1
Sreekanth
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or