473,386 Members | 1,823 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.

Cross tab, DataGrid, Templates

Hi everyone,

I have a web form that asks the user what languages he speaks and what his
skill level is. I used a DataGrid control bound to a table that contains
the languages and three template columns (beginner, intermediate, expert)
that contain a radio button control. Now, only one skill level can be
selected per language, so I tried to give the same name to the radio button
control. When the page loads for the first time, everything is fine, but
when there is a postback, I get an error message saying that the id for the
radio button must not be the same for the FindControl function to work.

How can I do this differently?
Nov 18 '05 #1
5 1925
Hi Eric:
"I tried to give the same name to the radio button
control."
Can you give an show us your template columns?

The DataGrid should automatically provide unique names for the server
controls inside. See my article for some tips and details:

In Search of ASP.NET Controls
http://odetocode.com/Articles/116.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 30 Sep 2004 14:25:08 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:
Hi everyone,

I have a web form that asks the user what languages he speaks and what his
skill level is. I used a DataGrid control bound to a table that contains
the languages and three template columns (beginner, intermediate, expert)
that contain a radio button control. Now, only one skill level can be
selected per language, so I tried to give the same name to the radio button
control. When the page loads for the first time, everything is fine, but
when there is a postback, I get an error message saying that the id for the
radio button must not be the same for the FindControl function to work.

How can I do this differently?


Nov 18 '05 #2
Hi Scott,

Here's the DataGrid layout:

<asp:datagrid id="dgLangues" runat="server" CssClass="list" Width="70%"
CellSpacing="1" AutoGenerateColumns="False" GridLines="None"
HorizontalAlign="Center" CellPadding="4">
<SelectedItemStyle CssClass="listselected"></SelectedItemStyle>
<EditItemStyle CssClass="listedit"></EditItemStyle>
<AlternatingItemStyle CssClass="list2"></AlternatingItemStyle>
<ItemStyle CssClass="list1"></ItemStyle>
<HeaderStyle BorderStyle="Solid" CssClass="listheader"></HeaderStyle>
<FooterStyle CssClass="listfooter"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="LangueNom" HeaderText="Langue(s)">
<HeaderStyle Width="25%"></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Niveau élémentaire">
<HeaderStyle HorizontalAlign="Center" Width="25%"
VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<P align="center">
<asp:RadioButton id="radNiveauLangue"
runat="server"></asp:RadioButton></P>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"
VerticalAlign="Middle"></FooterStyle>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Niveau intermédiaire">
<HeaderStyle HorizontalAlign="Center" Width="25%"
VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<asp:RadioButton id="radNiveauLangue" runat="server"></asp:RadioButton>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"
VerticalAlign="Middle"></FooterStyle>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Niveau avancé">
<HeaderStyle HorizontalAlign="Center" Width="25%"
VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<asp:RadioButton id="radNiveauLangue" runat="server"></asp:RadioButton>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center"
VerticalAlign="Middle"></FooterStyle>
</asp:TemplateColumn>
</Columns>
<PagerStyle CssClass="listpager"></PagerStyle>
</asp:datagrid>

Another related question, how can I save the ID of each row in my datagrid?

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:7e********************************@4ax.com...
Hi Eric:
"I tried to give the same name to the radio button
control."


Can you give an show us your template columns?

The DataGrid should automatically provide unique names for the server
controls inside. See my article for some tips and details:

In Search of ASP.NET Controls
http://odetocode.com/Articles/116.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 30 Sep 2004 14:25:08 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:
Hi everyone,

I have a web form that asks the user what languages he speaks and what hisskill level is. I used a DataGrid control bound to a table that contains
the languages and three template columns (beginner, intermediate, expert)
that contain a radio button control. Now, only one skill level can be
selected per language, so I tried to give the same name to the radio buttoncontrol. When the page loads for the first time, everything is fine, but
when there is a postback, I get an error message saying that the id for theradio button must not be the same for the FindControl function to work.

How can I do this differently?

Nov 18 '05 #3
On Thu, 30 Sep 2004 15:00:36 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:

HI Eric:
Hi Scott,

Here's the DataGrid layout:

Ah, so you have multiple radio buttons in each row. In this case you
do need to give each radio button control a unique id. Like
radNiveauLangueBeginner, radNiveauLangueAdvanced (sorry, my french is
rusty). If you call FindControl("radNiveauLangueBeginner") on each row
(a DataGridItem, to be precise), FindControl will be able to find each
control then.

Another related question, how can I save the ID of each row in my datagrid?

One way is to use the DataKeyField and DataKeys property of the grid.

HTH,

--
Scott
http://www.OdeToCode.com/
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:7e********************************@4ax.com.. .
Hi Eric:
>"I tried to give the same name to the radio button
>control."


Can you give an show us your template columns?

The DataGrid should automatically provide unique names for the server
controls inside. See my article for some tips and details:

In Search of ASP.NET Controls
http://odetocode.com/Articles/116.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 30 Sep 2004 14:25:08 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:
>Hi everyone,
>
>I have a web form that asks the user what languages he speaks and whathis >skill level is. I used a DataGrid control bound to a table that contains
>the languages and three template columns (beginner, intermediate, expert)
>that contain a radio button control. Now, only one skill level can be
>selected per language, so I tried to give the same name to the radiobutton >control. When the page loads for the first time, everything is fine, but
>when there is a postback, I get an error message saying that the id forthe >radio button must not be the same for the FindControl function to work.
>
>How can I do this differently?
>


Nov 18 '05 #4
Hi Scott,

This is the way I had done it in the first place, but I need to select only
one language skill level per row. Is there a way to do this without doing a
postback? Using ASP 3.0, I would have generated each row using a name built
using the ID of the language, but I would have used the same name for all
three columns. Now, do I have to write a messy javascript function to keep
track of all those radio buttons? And even so, I don't even know where to
begin...

Can I somehow generate the name/id of the radio button control while binding
the datagrid? Is there another template control that would do a better job
for this kind of situation?

Thanks for your help!

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:r4********************************@4ax.com...
On Thu, 30 Sep 2004 15:00:36 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:

HI Eric:
Hi Scott,

Here's the DataGrid layout:


Ah, so you have multiple radio buttons in each row. In this case you
do need to give each radio button control a unique id. Like
radNiveauLangueBeginner, radNiveauLangueAdvanced (sorry, my french is
rusty). If you call FindControl("radNiveauLangueBeginner") on each row
(a DataGridItem, to be precise), FindControl will be able to find each
control then.

Another related question, how can I save the ID of each row in my datagrid?


One way is to use the DataKeyField and DataKeys property of the grid.

HTH,

--
Scott
http://www.OdeToCode.com/
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:7e********************************@4ax.com.. .
Hi Eric:

>"I tried to give the same name to the radio button
>control."

Can you give an show us your template columns?

The DataGrid should automatically provide unique names for the server
controls inside. See my article for some tips and details:

In Search of ASP.NET Controls
http://odetocode.com/Articles/116.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 30 Sep 2004 14:25:08 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:

>Hi everyone,
>
>I have a web form that asks the user what languages he speaks and what

his
>skill level is. I used a DataGrid control bound to a table that contains >the languages and three template columns (beginner, intermediate, expert) >that contain a radio button control. Now, only one skill level can be
>selected per language, so I tried to give the same name to the radio

button
>control. When the page loads for the first time, everything is fine, but >when there is a postback, I get an error message saying that the id for
the
>radio button must not be the same for the FindControl function to

work. >
>How can I do this differently?
>

Nov 18 '05 #5
Hi Eric:

If understand what you are trying to do, perhaps you want to fall back
to HTML elements and avoid the server side radio button control. Then
you can name then what you would like and handle them with javascript.

--s

On Thu, 30 Sep 2004 17:28:42 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:
Hi Scott,

This is the way I had done it in the first place, but I need to select only
one language skill level per row. Is there a way to do this without doing a
postback? Using ASP 3.0, I would have generated each row using a name built
using the ID of the language, but I would have used the same name for all
three columns. Now, do I have to write a messy javascript function to keep
track of all those radio buttons? And even so, I don't even know where to
begin...

Can I somehow generate the name/id of the radio button control while binding
the datagrid? Is there another template control that would do a better job
for this kind of situation?

Thanks for your help!

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:r4********************************@4ax.com.. .
On Thu, 30 Sep 2004 15:00:36 -0400, "Eric Caron"
<ec****@nospam.quebecaffaires.com> wrote:

HI Eric:
>Hi Scott,
>
>Here's the DataGrid layout:
>


Ah, so you have multiple radio buttons in each row. In this case you
do need to give each radio button control a unique id. Like
radNiveauLangueBeginner, radNiveauLangueAdvanced (sorry, my french is
rusty). If you call FindControl("radNiveauLangueBeginner") on each row
(a DataGridItem, to be precise), FindControl will be able to find each
control then.
>
>Another related question, how can I save the ID of each row in mydatagrid? >


One way is to use the DataKeyField and DataKeys property of the grid.

HTH,

--
Scott
http://www.OdeToCode.com/
>"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
>news:7e********************************@4ax.com.. .
>> Hi Eric:
>>
>> >"I tried to give the same name to the radio button
>> >control."
>>
>> Can you give an show us your template columns?
>>
>> The DataGrid should automatically provide unique names for the server
>> controls inside. See my article for some tips and details:
>>
>> In Search of ASP.NET Controls
>> http://odetocode.com/Articles/116.aspx
>>
>> --
>> Scott
>> http://www.OdeToCode.com/blogs/scott/
>>
>> On Thu, 30 Sep 2004 14:25:08 -0400, "Eric Caron"
>> <ec****@nospam.quebecaffaires.com> wrote:
>>
>> >Hi everyone,
>> >
>> >I have a web form that asks the user what languages he speaks and what
>his
>> >skill level is. I used a DataGrid control bound to a table thatcontains >> >the languages and three template columns (beginner, intermediate,expert) >> >that contain a radio button control. Now, only one skill level can be
>> >selected per language, so I tried to give the same name to the radio
>button
>> >control. When the page loads for the first time, everything is fine,but >> >when there is a postback, I get an error message saying that the idfor >the
>> >radio button must not be the same for the FindControl function towork. >> >
>> >How can I do this differently?
>> >
>>
>


--
Scott
http://www.OdeToCode.com/
Nov 18 '05 #6

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

Similar topics

3
by: rollasoc | last post by:
Hi, Doing a bit of system testing on a Windows 98 laptop. (.Net 1.1 app). Did a bit of testing. Loaded a previously saved file. A gray box appeared with the text and buttons all white...
3
by: Thomas | last post by:
hi, - I use the datagrid without a real database, only to display my memory data and it works fine. - If I install the application at an other computer the datagrid doesn't work and disappear,...
0
by: Shakthi | last post by:
Hi Friends I have bounded dataset to a datagrid on pageload event datagrid is not visible. Once the query fetches more than 0 rows based on the selection criteria, datagrid is visible. If query...
2
by: Alex Smith | last post by:
Hi friends Can anybody tell me where to use datagrid and where to use datalist. Or explain Different between DataGrid and DataList. Regards, Alex
2
by: TFS | last post by:
Hi, I know the topic of cross-thread operations from the UI has been addressed several times, but if anyone could provide some insight for my particular scenario, I would be thankful... Using...
4
by: __Stephen | last post by:
Sorry about the cross-post. "Life would be so much easier it we didn't have end users" :) I have an ASP.NET app that delivers a cross tab report to our Accounting Department. CFO just demanded...
12
by: XShadow | last post by:
Hi, I'm working on a new cross platform c++ framework, I principally wrote it for fun in my spare time. The project becomes rather large so I decided to make it available on the web in the hope...
3
by: Rick | last post by:
If I create a class that inherits from the asp.net datagrid, and the enhancements only relate to the codebehind, what does the grid's html look like in design mode? I mean, whereas I might have an...
0
by: slemen | last post by:
Hi, The DataGrid aps:EditCommandColumn when used with column templates created programmatically does not trigger the _Edit subroutine in code. The ASP:Datagrid definition is below (1), the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.