473,405 Members | 2,344 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,405 software developers and data experts.

GridView - RadioButton for survey, idea needed

hello,

based on a client login I call a GridView that presents the appropriate
questionnaire for that person. I added three columns (template fields)
to the gridview that are radiobuttons. The client has to choose one
radiobutton per row (either YES, NO, or PERHAPS). Yes would have a
value of 1, No 2, perhaps 3.

1) I need to restrict the choice to one of the three radiobuttons ?
2) Need to insert the client's choice for every row in my table.

maybe someone could fix the general idea below or propose somethnig
else

For each row in Gridview1.rows
If (radiobutton1 = true) then result = 1
ElseIf (radiobutton1 = true) then result = 2
ElseIf (radiobutton1 = true) then result = 3
EndIf
resultrow = result
Next
Then again, i would need as many resultrow variables as there are rows,
then I would do one insert because in my final table one line is one
client and all his answers

Thanks you

Sep 6 '06 #1
4 2297
Salut Patrik,

It might be easier to put all of the choices in one column and then grab the
selected value from that. Here's a little sample in case it gives you an
idea. BTW, this uses the editable XMLDataSource from http://www.chaliy.com/
..

Let us know?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>
<%@ register assembly="Chaliy.Web.UI.UpdatableXmlDataSource"
namespace="Chaliy.Web.UI" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Radio Buttons in Gridview</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server" allowpaging="True"
allowsorting="True" autogeneratecolumns="False"
autogeneratedeletebutton="True" autogenerateeditbutton="True"
datasourceid="UpdatableXmlDataSource1">
<columns>
<asp:templatefield headertext="Choice"
sortexpression="Choice">
<edititemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</edititemtemplate>
<itemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="StringValue"
headertext="StringValue" sortexpression="StringValue" />
<asp:boundfield datafield="CurrencyValue"
headertext="CurrencyValue" sortexpression="CurrencyValue" />
<asp:boundfield datafield="Boolean" headertext="Boolean"
sortexpression="Boolean" />
</columns>
</asp:gridview>

<asp:hyperlink id="AddNewHyperLink" runat="server"
navigateurl="~/AddNew.aspx">Add new</asp:hyperlink>
<cc1:updatablexmldatasource id="UpdatableXmlDataSource1"
runat="server" datafile="~/App_Data/TestData.xml" filterxpath="/Item"
rootxpath="Data">
<data>
</data>
</cc1:updatablexmldatasource>

</div>
</form>
</body>
</html>

<?xml version="1.0" encoding="utf-8"?>
<Data>
<Item Choice="3" StringValue="Item1" CurrencyValue="1.99" Boolean="True"
/>
<Item Choice="2" StringValue="Item2" CurrencyValue="2.99" Boolean="True"
/>
<Item Choice="2" StringValue="Item3" CurrencyValue="3.99" Boolean="True"
/>
<Item Choice="3" StringValue="Item4" CurrencyValue="5.99" Boolean="True"
/>
<Item Choice="3" StringValue="Item5" CurrencyValue="4.99" Boolean="True"
/>
</Data>
"Patrik" <pa***********@umontreal.cawrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
hello,

based on a client login I call a GridView that presents the appropriate
questionnaire for that person. I added three columns (template fields)
to the gridview that are radiobuttons. The client has to choose one
radiobutton per row (either YES, NO, or PERHAPS). Yes would have a
value of 1, No 2, perhaps 3.

1) I need to restrict the choice to one of the three radiobuttons ?
2) Need to insert the client's choice for every row in my table.

maybe someone could fix the general idea below or propose somethnig
else

For each row in Gridview1.rows
If (radiobutton1 = true) then result = 1
ElseIf (radiobutton1 = true) then result = 2
ElseIf (radiobutton1 = true) then result = 3
EndIf
resultrow = result
Next
Then again, i would need as many resultrow variables as there are rows,
then I would do one insert because in my final table one line is one
client and all his answers

Thanks you

Sep 6 '06 #2
Thank you for the suggestion,

I have to admit this would be quite easier, but for the actual task I
have 5 choices (rating scale) and up to 40 questions, this would be to
costly in space and my clients are used to the layout on paper.

So I really have to figure it out. I CANNOT believe how difficult this
seems and that no one had a similar problem, I have been reading for
two days everywhere.

I'll try some more and then I'll surrender for your option I guess.
Ken Cox [Microsoft MVP] a écrit :
Salut Patrik,

It might be easier to put all of the choices in one column and then grab the
selected value from that. Here's a little sample in case it gives you an
idea. BTW, this uses the editable XMLDataSource from http://www.chaliy.com/
.

Let us know?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>
<%@ register assembly="Chaliy.Web.UI.UpdatableXmlDataSource"
namespace="Chaliy.Web.UI" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Radio Buttons in Gridview</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server" allowpaging="True"
allowsorting="True" autogeneratecolumns="False"
autogeneratedeletebutton="True" autogenerateeditbutton="True"
datasourceid="UpdatableXmlDataSource1">
<columns>
<asp:templatefield headertext="Choice"
sortexpression="Choice">
<edititemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</edititemtemplate>
<itemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="StringValue"
headertext="StringValue" sortexpression="StringValue" />
<asp:boundfield datafield="CurrencyValue"
headertext="CurrencyValue" sortexpression="CurrencyValue" />
<asp:boundfield datafield="Boolean" headertext="Boolean"
sortexpression="Boolean" />
</columns>
</asp:gridview>

<asp:hyperlink id="AddNewHyperLink" runat="server"
navigateurl="~/AddNew.aspx">Add new</asp:hyperlink>
<cc1:updatablexmldatasource id="UpdatableXmlDataSource1"
runat="server" datafile="~/App_Data/TestData.xml" filterxpath="/Item"
rootxpath="Data">
<data>
</data>
</cc1:updatablexmldatasource>

</div>
</form>
</body>
</html>

<?xml version="1.0" encoding="utf-8"?>
<Data>
<Item Choice="3" StringValue="Item1" CurrencyValue="1.99" Boolean="True"
/>
<Item Choice="2" StringValue="Item2" CurrencyValue="2.99" Boolean="True"
/>
<Item Choice="2" StringValue="Item3" CurrencyValue="3.99" Boolean="True"
/>
<Item Choice="3" StringValue="Item4" CurrencyValue="5.99" Boolean="True"
/>
<Item Choice="3" StringValue="Item5" CurrencyValue="4.99" Boolean="True"
/>
</Data>
"Patrik" <pa***********@umontreal.cawrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
hello,

based on a client login I call a GridView that presents the appropriate
questionnaire for that person. I added three columns (template fields)
to the gridview that are radiobuttons. The client has to choose one
radiobutton per row (either YES, NO, or PERHAPS). Yes would have a
value of 1, No 2, perhaps 3.

1) I need to restrict the choice to one of the three radiobuttons ?
2) Need to insert the client's choice for every row in my table.

maybe someone could fix the general idea below or propose somethnig
else

For each row in Gridview1.rows
If (radiobutton1 = true) then result = 1
ElseIf (radiobutton1 = true) then result = 2
ElseIf (radiobutton1 = true) then result = 3
EndIf
resultrow = result
Next
Then again, i would need as many resultrow variables as there are rows,
then I would do one insert because in my final table one line is one
client and all his answers

Thanks you
Sep 7 '06 #3
Here's how I am solving it :
radiobuttonlist in the itemtemplate, i make it horizontal, then i add a
table on top of the grid to insert the headertext for the buttons.
Patrik a écrit :
Thank you for the suggestion,

I have to admit this would be quite easier, but for the actual task I
have 5 choices (rating scale) and up to 40 questions, this would be to
costly in space and my clients are used to the layout on paper.

So I really have to figure it out. I CANNOT believe how difficult this
seems and that no one had a similar problem, I have been reading for
two days everywhere.

I'll try some more and then I'll surrender for your option I guess.
Ken Cox [Microsoft MVP] a écrit :
Salut Patrik,

It might be easier to put all of the choices in one column and then grab the
selected value from that. Here's a little sample in case it gives you an
idea. BTW, this uses the editable XMLDataSource from http://www.chaliy.com/
.

Let us know?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>
<%@ register assembly="Chaliy.Web.UI.UpdatableXmlDataSource"
namespace="Chaliy.Web.UI" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Radio Buttons in Gridview</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server" allowpaging="True"
allowsorting="True" autogeneratecolumns="False"
autogeneratedeletebutton="True" autogenerateeditbutton="True"
datasourceid="UpdatableXmlDataSource1">
<columns>
<asp:templatefield headertext="Choice"
sortexpression="Choice">
<edititemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</edititemtemplate>
<itemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="StringValue"
headertext="StringValue" sortexpression="StringValue" />
<asp:boundfield datafield="CurrencyValue"
headertext="CurrencyValue" sortexpression="CurrencyValue" />
<asp:boundfield datafield="Boolean" headertext="Boolean"
sortexpression="Boolean" />
</columns>
</asp:gridview>

<asp:hyperlink id="AddNewHyperLink" runat="server"
navigateurl="~/AddNew.aspx">Add new</asp:hyperlink>
<cc1:updatablexmldatasource id="UpdatableXmlDataSource1"
runat="server" datafile="~/App_Data/TestData.xml" filterxpath="/Item"
rootxpath="Data">
<data>
</data>
</cc1:updatablexmldatasource>

</div>
</form>
</body>
</html>

<?xml version="1.0" encoding="utf-8"?>
<Data>
<Item Choice="3" StringValue="Item1" CurrencyValue="1.99" Boolean="True"
/>
<Item Choice="2" StringValue="Item2" CurrencyValue="2.99" Boolean="True"
/>
<Item Choice="2" StringValue="Item3" CurrencyValue="3.99" Boolean="True"
/>
<Item Choice="3" StringValue="Item4" CurrencyValue="5.99" Boolean="True"
/>
<Item Choice="3" StringValue="Item5" CurrencyValue="4.99" Boolean="True"
/>
</Data>
"Patrik" <pa***********@umontreal.cawrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
hello,
>
based on a client login I call a GridView that presents the appropriate
questionnaire for that person. I added three columns (template fields)
to the gridview that are radiobuttons. The client has to choose one
radiobutton per row (either YES, NO, or PERHAPS). Yes would have a
value of 1, No 2, perhaps 3.
>
1) I need to restrict the choice to one of the three radiobuttons ?
2) Need to insert the client's choice for every row in my table.
>
maybe someone could fix the general idea below or propose somethnig
else
>
For each row in Gridview1.rows
If (radiobutton1 = true) then result = 1
ElseIf (radiobutton1 = true) then result = 2
ElseIf (radiobutton1 = true) then result = 3
EndIf
resultrow = result
Next
Then again, i would need as many resultrow variables as there are rows,
then I would do one insert because in my final table one line is one
client and all his answers
>
Thanks you
>
Sep 7 '06 #4
Sounds good!

"Patrik" <pa***********@umontreal.cawrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Here's how I am solving it :
radiobuttonlist in the itemtemplate, i make it horizontal, then i add a
table on top of the grid to insert the headertext for the buttons.
Patrik a écrit :
Thank you for the suggestion,

I have to admit this would be quite easier, but for the actual task I
have 5 choices (rating scale) and up to 40 questions, this would be to
costly in space and my clients are used to the layout on paper.

So I really have to figure it out. I CANNOT believe how difficult this
seems and that no one had a similar problem, I have been reading for
two days everywhere.

I'll try some more and then I'll surrender for your option I guess.
Ken Cox [Microsoft MVP] a écrit :
Salut Patrik,

It might be easier to put all of the choices in one column and then grab
the
selected value from that. Here's a little sample in case it gives you an
idea. BTW, this uses the editable XMLDataSource from
http://www.chaliy.com/
.

Let us know?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>
<%@ register assembly="Chaliy.Web.UI.UpdatableXmlDataSource"
namespace="Chaliy.Web.UI" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Radio Buttons in Gridview</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server" allowpaging="True"
allowsorting="True" autogeneratecolumns="False"
autogeneratedeletebutton="True" autogenerateeditbutton="True"
datasourceid="UpdatableXmlDataSource1">
<columns>
<asp:templatefield headertext="Choice"
sortexpression="Choice">
<edititemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem
value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</edititemtemplate>
<itemtemplate>
<asp:radiobuttonlist id="RadioButtonList1"
runat="server" selectedvalue='<%# Bind("Choice") %>'>
<asp:listitem value="1">Yes</asp:listitem>
<asp:listitem value="2">No</asp:listitem>
<asp:listitem
value="3">Perhaps</asp:listitem>
</asp:radiobuttonlist>
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="StringValue"
headertext="StringValue" sortexpression="StringValue" />
<asp:boundfield datafield="CurrencyValue"
headertext="CurrencyValue" sortexpression="CurrencyValue" />
<asp:boundfield datafield="Boolean" headertext="Boolean"
sortexpression="Boolean" />
</columns>
</asp:gridview>

<asp:hyperlink id="AddNewHyperLink" runat="server"
navigateurl="~/AddNew.aspx">Add new</asp:hyperlink>
<cc1:updatablexmldatasource id="UpdatableXmlDataSource1"
runat="server" datafile="~/App_Data/TestData.xml" filterxpath="/Item"
rootxpath="Data">
<data>
</data>
</cc1:updatablexmldatasource>

</div>
</form>
</body>
</html>

<?xml version="1.0" encoding="utf-8"?>
<Data>
<Item Choice="3" StringValue="Item1" CurrencyValue="1.99"
Boolean="True"
/>
<Item Choice="2" StringValue="Item2" CurrencyValue="2.99"
Boolean="True"
/>
<Item Choice="2" StringValue="Item3" CurrencyValue="3.99"
Boolean="True"
/>
<Item Choice="3" StringValue="Item4" CurrencyValue="5.99"
Boolean="True"
/>
<Item Choice="3" StringValue="Item5" CurrencyValue="4.99"
Boolean="True"
/>
</Data>
"Patrik" <pa***********@umontreal.cawrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
hello,
>
based on a client login I call a GridView that presents the
appropriate
questionnaire for that person. I added three columns (template fields)
to the gridview that are radiobuttons. The client has to choose one
radiobutton per row (either YES, NO, or PERHAPS). Yes would have a
value of 1, No 2, perhaps 3.
>
1) I need to restrict the choice to one of the three radiobuttons ?
2) Need to insert the client's choice for every row in my table.
>
maybe someone could fix the general idea below or propose somethnig
else
>
For each row in Gridview1.rows
If (radiobutton1 = true) then result = 1
ElseIf (radiobutton1 = true) then result = 2
ElseIf (radiobutton1 = true) then result = 3
EndIf
resultrow = result
Next
Then again, i would need as many resultrow variables as there are
rows,
then I would do one insert because in my final table one line is one
client and all his answers
>
Thanks you
>

Sep 7 '06 #5

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

Similar topics

3
by: sofie | last post by:
Hello all, I use the following javascript function in a html document to set the level of one of eight available radiobuttons. The line that's commented out works fine under IE, but I need to...
1
by: Krish | last post by:
Hello Gurus, I have GridView control on web page which has couple of radio button controls as one group. On editing a particular row in grid, i have to validate based on user selection on radio...
0
by: Maarten | last post by:
Hi all, I have a datagrid (GridView) with questions where the user has to make a choice (yes or no questions) But for some questions there are rules, like if you choose (yes or no) for some...
1
by: Merichel | last post by:
Hi everybody, I would like to have a gridview with a radiobutton column in order to select just a row and do some task. I added a templatefield but when I run the application, it let me select...
7
by: Badis | last post by:
Hi, I've a radiobutton in my gridview and I want to dislpay the value in a cell of the selected value on the RadioButton click using this code : TextBox.Text =...
1
by: Eric Effer | last post by:
Hi everyone I am tryin to get the selected index from this gridview while selecting the radiobuttonlist. I dont want to use a button for the row though. Anyone knows how to do this? thnks ...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
2
by: CJM | last post by:
I have a page that allows the user to search a DB by querying one of 3 fields. When results are returned, I want the user to be able to click a value in one of three columns (that directly relate...
0
by: | last post by:
I am using radiobuttons in a gridview, and not a column of radiobuttons. I have one cell in each row with several radiobuttons that the user has to choose a radiobutton within each row. How can I...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.