473,609 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

posting radiobuttons inside a gridview do not persist selection after postback..

Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.
Nov 15 '06 #1
10 6678

enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.
Nov 15 '06 #2
Thanks, for the reply. However, I already have the enableviewstate set to
true,
and the problem is that in this snippet, the control variable comes null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadioB utton rb =
(HtmlInputRadio Button)(row.Fin dControl("rbMon day"));

if (rb.Checked == true)

{

Response.Write( "found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
>
enable viewstate on the radiobutton control in the template field?

Carlos wrote:
>Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.

Nov 15 '06 #3

Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
Thanks, for the reply. However, I already have the enableviewstate set to
true,
and the problem is that in this snippet, the control variable comes null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadioB utton rb =
(HtmlInputRadio Button)(row.Fin dControl("rbMon day"));

if (rb.Checked == true)

{

Response.Write( "found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .

enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.
Nov 15 '06 #4
Kevin, thanks again for the continued support.

Here is my gridview html.

<asp:GridView ID="GridView2" runat="server" style="left: 7px; position:
static; top: 116px" AutoGenerateCol umns="False" CellPadding="3"
GridLines="None " Width="230px" BackColor="Whit e" BorderColor="#D EDFDE"
BorderWidth="0p x" CellSpacing="1" >

<FooterStyle BackColor="#C6C 3C6" ForeColor="Blac k" />

<Columns>

<asp:TemplateFi eld HeaderText="(Se lect One">

<ItemTemplate >

<input name="rbMonday" type="radio" enableviewstate ="true" runat="server"
value='<%# Eval("payment") %>' />

</ItemTemplate>

<HeaderStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="X-Small" BackColor="Blac k" HorizontalAlign ="Left"
VerticalAlign=" Middle" Width="40px" Wrap="False" />

<ItemStyle HorizontalAlign ="Center" VerticalAlign=" Middle" Wrap="True" />

</asp:TemplateFie ld>

<asp:BoundFie ld DataField="paym ent" HeaderText="Pay ment" >

<ItemStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="XX-Small" HorizontalAlign ="Left" VerticalAlign=" Middle"
Wrap="True" />

<HeaderStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="X-Small" BackColor="Blac k" ForeColor="Whit e"
HorizontalAlign ="Center" VerticalAlign=" Middle" Wrap="False" />

</asp:BoundField>

</Columns>

<RowStyle BackColor="#DED FDE" ForeColor="Blac k" />

<SelectedRowSty le BackColor="#947 1DE" Font-Bold="True" ForeColor="Whit e" />

<PagerStyle BackColor="#C6C 3C6" ForeColor="Blac k" HorizontalAlign ="Right" />

<HeaderStyle BackColor="#4A3 C8C" Font-Bold="True" ForeColor="#E7E 7FF" />

</asp:GridView>

Thanks again,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
>
Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
>Thanks, for the reply. However, I already have the enableviewstate set to
true,
and the problem is that in this snippet, the control variable comes null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadio Button rb =
(HtmlInputRadi oButton)(row.Fi ndControl("rbMo nday"));

if (rb.Checked == true)

{

Response.Write ("found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
>
enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.

Nov 15 '06 #5

just quickly perusing your html for the radio button, try making sure
there is an id.

<input id="rbMonday" name="rbMonday" type="radio"
enableviewstate ="true" runat="server"v alue='<%# Eval("payment") %>'
/>


Carlos wrote:
Kevin, thanks again for the continued support.

Here is my gridview html.

<asp:GridView ID="GridView2" runat="server" style="left: 7px; position:
static; top: 116px" AutoGenerateCol umns="False" CellPadding="3"
GridLines="None " Width="230px" BackColor="Whit e" BorderColor="#D EDFDE"
BorderWidth="0p x" CellSpacing="1" >

<FooterStyle BackColor="#C6C 3C6" ForeColor="Blac k" />

<Columns>

<asp:TemplateFi eld HeaderText="(Se lect One">

<ItemTemplate >

<input name="rbMonday" type="radio" enableviewstate ="true" runat="server"
value='<%# Eval("payment") %>' />

</ItemTemplate>

<HeaderStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="X-Small" BackColor="Blac k" HorizontalAlign ="Left"
VerticalAlign=" Middle" Width="40px" Wrap="False" />

<ItemStyle HorizontalAlign ="Center" VerticalAlign=" Middle" Wrap="True" />

</asp:TemplateFie ld>

<asp:BoundFie ld DataField="paym ent" HeaderText="Pay ment" >

<ItemStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="XX-Small" HorizontalAlign ="Left" VerticalAlign=" Middle"
Wrap="True" />

<HeaderStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="X-Small" BackColor="Blac k" ForeColor="Whit e"
HorizontalAlign ="Center" VerticalAlign=" Middle" Wrap="False" />

</asp:BoundField>

</Columns>

<RowStyle BackColor="#DED FDE" ForeColor="Blac k" />

<SelectedRowSty le BackColor="#947 1DE" Font-Bold="True" ForeColor="Whit e" />

<PagerStyle BackColor="#C6C 3C6" ForeColor="Blac k" HorizontalAlign ="Right" />

<HeaderStyle BackColor="#4A3 C8C" Font-Bold="True" ForeColor="#E7E 7FF" />

</asp:GridView>

Thanks again,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...

Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
Thanks, for the reply. However, I already have the enableviewstate set to
true,
and the problem is that in this snippet, the control variable comes null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadioB utton rb =
(HtmlInputRadio Button)(row.Fin dControl("rbMon day"));

if (rb.Checked == true)

{

Response.Write( "found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .

enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.
Nov 15 '06 #6

Kevin,

The problem with having the runat="server" in the html radio button, is that
even though it keeps the selected item, when I select other item(s),
the other selections remain., and can not be un-selected.

here is the itemtemplate:

<ItemTemplate >

<input name="rbMonday" type="radio" enableviewstate ="true" value='<%#
Eval("song") %>' />

</ItemTemplate>
Thanks again

Carlos

"kferron" <ke**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
>
Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
>Thanks, for the reply. However, I already have the enableviewstate set to
true,
and the problem is that in this snippet, the control variable comes null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadio Button rb =
(HtmlInputRadi oButton)(row.Fi ndControl("rbMo nday"));

if (rb.Checked == true)

{

Response.Write ("found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
>
enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.

Nov 20 '06 #7

well, thats an html issue.. if you want the radio buttons to behave
correctly you will need to name them all the same thing

Carlos wrote:
Kevin,

The problem with having the runat="server" in the html radio button, is that
even though it keeps the selected item, when I select other item(s),
the other selections remain., and can not be un-selected.

here is the itemtemplate:

<ItemTemplate >

<input name="rbMonday" type="radio" enableviewstate ="true" value='<%#
Eval("song") %>' />

</ItemTemplate>
Thanks again

Carlos

"kferron" <ke**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...

Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
Thanks, for the reply. However, I already have the enableviewstate set to
true,
and the problem is that in this snippet, the control variable comes null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadioB utton rb =
(HtmlInputRadio Button)(row.Fin dControl("rbMon day"));

if (rb.Checked == true)

{

Response.Write( "found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .

enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.
Nov 21 '06 #8
kferron is right...
Furthermore you can find a number of articles on CodeProject on how to group
radio buttons on asp.net.

HTH
_______________ _____
Konstantinos Pantos
MCP Software Engineer
"Carlos" <ch******@yahoo .comwrote in message
news:uE******** *****@TK2MSFTNG P04.phx.gbl...
>
Kevin,

The problem with having the runat="server" in the html radio button, is
that
even though it keeps the selected item, when I select other item(s),
the other selections remain., and can not be un-selected.

here is the itemtemplate:

<ItemTemplate >

<input name="rbMonday" type="radio" enableviewstate ="true" value='<%#
Eval("song") %>' />

</ItemTemplate>
Thanks again

Carlos

"kferron" <ke**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
>>
Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
>>Thanks, for the reply. However, I already have the enableviewstate set
to
true,
and the problem is that in this snippet, the control variable comes
null.
i.e. apparently it can not find the control:

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

{

GridViewRow row = GridView11.Rows[i];

HtmlInputRadi oButton rb =
(HtmlInputRad ioButton)(row.F indControl("rbM onday"));

if (rb.Checked == true)

{

Response.Writ e("found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11****** *************** *@h48g2000cwc.g ooglegroups.com ...

enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know
how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.

Nov 21 '06 #9
I thank you all for your kind response. However, I believe that
it does not address the issue. I am using html radiobuttons because
I read somewhere that it was better because you just need to get
their values issuing a request.form with the name of the control
within a template. However, after a postback if a user needs to see
what it had selected there is no way for the selection to remain.

My question is if there is an efficient sample somewhere that I can look at.

Thanks,

Carlos.

"Konstantin os Pantos" <ko***********@ hotmail.comwrot e in message
news:CE******** *************** ***********@mic rosoft.com...
kferron is right...
Furthermore you can find a number of articles on CodeProject on how to
group radio buttons on asp.net.

HTH
_______________ _____
Konstantinos Pantos
MCP Software Engineer
"Carlos" <ch******@yahoo .comwrote in message
news:uE******** *****@TK2MSFTNG P04.phx.gbl...
>>
Kevin,

The problem with having the runat="server" in the html radio button, is
that
even though it keeps the selected item, when I select other item(s),
the other selections remain., and can not be un-selected.

here is the itemtemplate:

<ItemTemplat e>

<input name="rbMonday" type="radio" enableviewstate ="true" value='<%#
Eval("song") %>' />

</ItemTemplate>
Thanks again

Carlos

"kferron" <ke**********@g mail.comwrote in message
news:11******* **************@ i42g2000cwa.goo glegroups.com.. .
>>>
Do you have runat="server" in the html radio button?

Perhaps you could paste the templatefield html.
Carlos wrote:
Thanks, for the reply. However, I already have the enableviewstate set
to
true,
and the problem is that in this snippet, the control variable comes
null.
i.e. apparently it can not find the control:

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

{

GridViewRo w row = GridView11.Rows[i];

HtmlInputRad ioButton rb =
(HtmlInputRa dioButton)(row. FindControl("rb Monday"));

if (rb.Checked == true)

{

Response.Wri te("found it..");


// Column 2 is the name column

}
}

Thanks,

Carlos.

"kferron" <ke**********@g mail.comwrote in message
news:11***** *************** **@h48g2000cwc. googlegroups.co m...

enable viewstate on the radiobutton control in the template field?

Carlos wrote:
Hi all,

I have a form with an input radio control in a template field.
When the user selects an option, and press a button
the selection disappears.. I would like the selection to
persist after the button makes the postback,

I tried using the findcontrol but it returns null, and do not know
how
to make sure that the radio selected persist after the button
action makes the postback.

Thanks in advance,

Carlos.



Nov 21 '06 #10

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

Similar topics

2
2752
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
3
10142
by: tarscher | last post by:
Hi all, I have a gridview populated with data coming from a dataset (created via the wizard). The data shown in the gridview is dependent on the the choice of a control (dropdown with autopostback enabled). When I load the page for the first time I the gridview is empty. When I select something in the dropdownlist the gridview is populated correctly. I guess this has something to do with the fact that the first time no data from the...
1
21460
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in the grid). Desired aciton is then taken in response to the button_onclick event relevant to the row in which the checked checkboxes exist. Unfortunate Outcome: Each checkbox returns false for its attribute:checked whether the user has placed a...
3
311
by: Gonza | last post by:
Hi group, i have a question relatred to gridview and postback (i should probably know this by now, considering i've been working with .net for a few years now, but baahh). Why could a gridview (regular gridview, no custom controls inside, bound to a list<custom object>) loose it's value after a postback. I know that the datasource is not saved in viewstate, but why are the rows getting cleared???? Thanks in advace Gonzalo, from...
2
16998
by: =?Utf-8?B?dmFuZGls?= | last post by:
I have a web app that I have been working on for the last couple of weeks trying to solve this problem. One page contains a GridView with four base columns, and an unknown number of columns to be added depending on the data source chosen. I create some TemplateColumns based on the data returned for the selection, and add them into the GridView using the following code: DataSet dsTraits = ssql_common.selectRubricTraits(sConnectionString,...
12
3799
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values in my 'onpageload' in the cs file.
0
4190
by: =?Utf-8?B?V0I=?= | last post by:
Hi, I have a .NET page which has a gridview of customers from Northwind database. There's a checkbox for each customer and the gridview allows paging. I would like to be able to persist the checkbox status while paging. I'm starting with the code below but I can't get it to work. You can check some of the checkboxes and when you click on the pager, no selection is reflected by the trace. Why's that?
0
2802
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation. What happened is if I select cancel on my confirmation button, it executes the griedview postback which i assigned in my code behind. Please see my codes below... Code beind: protected void gvDefectCatalog_RowDataBound(object sender,...
2
3725
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a gridview edit row that has a DropDownList in one column and a status Label in the 2nd column. When i changed the value in the dropdownlist, there's a client-side javascirpt function that runs and successfully populates label in the 2nd column. Everything is fine at this point and working the way it should. i do a getElementById to get the status label and then i set its innerHTML and again it works fine.
0
8145
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8095
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8588
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8410
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5526
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1690
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.