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

grid question

5 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saro
Top achievements
Rank 1
Saro asked on 03 May 2012, 12:32 AM
Hi,
I am new to telerik grid.
This is what I am trying to do.   I want to place a combo box or drop down box in a cell of a grid.  however, the grid is only being populated in the codebehind.
>>

 

List<KI_Controls.KI_Multimedia> oPrimaryMM = oPrimaryContact.GetAllMultimedia();

BindingList<cKIWebMultiMediaContent> Populatelist = new BindingList<cKIWebMultiMediaContent>();

 

 

 

for (int i = 0; i < oPrimaryMM.Count; i++)

{

 

 

cKIWebMultiMediaContent otemp = new cKIWebMultiMediaContent();

otemp.MultiMediaType = oPrimaryMM[i].Multimedia_Type;

otemp.MultiMediaText = oPrimaryMM[i].Value;

Populatelist.Add(otemp);

}

gridMainMultimedia.DataSource = Populatelist;


So this automatically creates 2 columns. MultiMediaType and MultiMediaText.

I want to make the MultiMediaType a dropdown and load it manually.

I see you have a lot of samples using datasources and design time binding.  Do you have a simple dropdown grid example which all is unbound?

5 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 07 May 2012, 09:17 AM
Hello Saro,

I would suggest that you use a GridTemplateColumn that has an empty dropdown list in its ItemTemplate. RadGrid supports programmatic creation as described in this help article. Note that column templates must be added in the Page_Init event handler, so that the template controls can be added to the ViewState.

I hope this helps.

Kind regards,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Saro
Top achievements
Rank 1
answered on 07 May 2012, 01:54 PM
This example really doesn't help me solve my issue.  When I have a grid completely unbound, I use needdatasource event handler and it works great.  How do I do the same with a column of an unbound grid which has a column type of dropdown? Again, the key here is that I am using completely ubound meaning I don't have a datasource until runtime and the datasource is most likely arrays.
Thanks
0
Richard
Top achievements
Rank 1
answered on 07 May 2012, 05:38 PM
Saro:

I would suggest that you review this forum thread for insights on how to display data that comes from an unbound data source (i.e. List):

Binding GridDropDownColumn in RadGrid

According to Telerik Admin: Veli (see his post dated June 24, 2010) -

"The GridDropDownColumn does not support manual data binding...Only declarative data sources and DataSets are supported by the GridDropDownColumn. It would probably be easier for you to just use a GridTemplateColumn with a RadComboBox in the EditItemTemplate."

To create a template dynamically, you must define a custom class that implements theITemplate interface. Then you can assign an instance of this class to the ItemTemplate or EditTemplateTemplate property of theGridTemplateColumn object.

You can reference the "Creating template columns programmatically" section of the Programmatic Creation RadGrid documentation page for insights on adding your columns using the code behind.

And, also take a look at the Operations with MS DropDownList in EditItemTemplate of GridTemplateColumn for further insights on binding and displaying selected values in the ItemTemplate.

Hope this helps!
0
Saro
Top achievements
Rank 1
answered on 07 May 2012, 06:02 PM
Hey thanks.  That explains why i can't do this.  But another question.  When I do use the combo, when the grid is not in edit mode, the combo appears as a combo box in the cell of a grid, not as a label. so the user can use a dropdown and change things.  I want the combo only to appear when in edit mode.  I am very new to this control and having a hard time understanding how to get this drop down to work.  If you can show me a simple sample would be great. 
0
Richard
Top achievements
Rank 1
answered on 07 May 2012, 06:20 PM
Saro:

Take a look at this forum thread. It should get you going in the right direction:

creating GridTemplateColumn in code behind

It demonstrates how to create the templates to be used for ItemTemplate and EditTemplate assignments.

You need to use an ASP:Label in your ItemTemplate that binds to the text value that you want to display.

I don't have a sample at hand, but I'll try to work one up, as time permits.

Cheers!
Tags
Grid
Asked by
Saro
Top achievements
Rank 1
Answers by
Martin
Telerik team
Saro
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or