473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Template column problem when adding datagrid via code

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/de...ridcontrol.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.
Nov 19 '05 #1
1 1457
RN
I figured out that I could just change the column data in the datagrid's
ItemDataBound event instead of elsewhere.
"RN" <re*************@please.com> wrote in message
news:R8******************@twister.socal.rr.com...
Hi. I used this article to add a template column to a datagrid that is
entirely created with code:

http://msdn.microsoft.com/library/de...ridcontrol.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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with TextBox,second with Button.I want to fire an event...
2
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four...
1
by: William Gower | last post by:
I need to develop a datagrid that uses columns from a table. In addition I need two columns (checkboxes) that the user will use to indicate that this record can be closed later. The checkboxed...
2
by: Suma | last post by:
I have a problem with editable datagrid and was hoping if anyone could help me. Please help me if possible. I have an editable datagrid, whose column count I don’t know until runtime. I am...
1
by: Dexter | last post by:
Hello all, I have a datagrid with "create columns automatically at run time" checked, and this datagrid show dynamic tables, then the column numbers is dynamic. I need to include a template...
0
by: wwcoop | last post by:
I am connected to an Access Database. I am reading a Yes/No field from the DB which translates back as True/False in the text field of my datagrid. I want to use a checkbox to show the value...
9
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to...
2
by: Javier | last post by:
Hi Everyone, I have a dynamic checkbox in a datagrid that uses the ITemplate interface and has the checkchanged event wired up. When the checkbox is checked, the event event handler that...
1
by: Abhishek | last post by:
I am creating a Datagrid at runtime and I have to create all the columns of grid at runtime... I am facing problem in the item template column. Here I want to place more than one control... For...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.