Template column problem when adding datagrid via code

R

RN

Hi. I used this article to add a template column to a datagrid that is
entirely created with code:

http://msdn.microsoft.com/library/d...emplatesprogrammaticallyindatagridcontrol.asp

It works fine except for one thing. My template column needs a field in the
recordset that binds to the datagrid. The template column is an HTML radio
button where the value of the radio button needs to be the ProductID field
in the recordset. As many of you may know, using radio buttons in a
datagrid invariably means using a template column, but the above code sample
doesn't help me understand how the "Case ListItemType.Item" section of code
(count 16 lines down their code sample) can possibly reference the field
name.

This "not so helpful" example puts "asdf" in the value field each time, but
it is not dynamic...

lc.Text = "<Input type=""Radio"" Name=""ProductID"" Value=""asdf"">"

BUT You obviously can't do:

lc.Text = "<Input type=""Radio"" Name=""ProductID"" Value=""" &
Container.DataItem("ProductID") ...

because Container.DataItem is not a recognizeable object in that section of
code (see 16 lines down the code sample in the article to see where I need
to reference the ProductID field of my dataset.

So how can I do this? Thanks.
 
R

RN

I figured out that I could just change the column data in the datagrid's
ItemDataBound event instead of elsewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top