.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
" yc=""><tr>
"><td> <strong> Gender: </ strong> </ td>
Post New Web Links


Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
 I need to do some custom render magic on an inherited RadioButtonList called ColourRadioButtonList.  As per the docs: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.renderitem(VS.80).aspxI've overridden the RenderItem method and started doing some juggling of my own RadioButton controls.  Plonked it into my nice page, databound it, but I'll be darned - RenderItem doesn't fire.  Before I start to go digging through the RadioButtonList code, is there something fundamental I'm missing here? public class ColourRadioButonList : RadioButtonList{ protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) { RadioButton radioButton = new RadioButton(); radioButton.Page = this.Page; radioButton.GroupName = this.UniqueID; radioButton.ID = this.ClientID + "_" + repeatIndex.ToString(); radioButton.Text = this.Items[repeatIndex].Text; radioButton.Attributes["value"] = this.Items[repeatIndex].Value; radioButton.Checked = this.Items[repeatIndex].Selected; radioButton.TextAlign = this.TextAlign; radioButton.AutoPostBack = this.AutoPostBack; radioButton.TabIndex = this.TabIndex; radioButton.Enabled = this.Enabled; radioButton.CssClass = InnerCssClass; radioButton.Style.Add(HtmlTextWriterStyle.BackgroundColor, this.Items[rep

View Complete Post

More Related Resource Links

Table format of RadioButtonList


Hi All,

I have radiobuttonlist with 3 listItem, i need to give the table format to radiobuttonlist means it looks like table with row, how can i give, Any idea?

My code:-

<asp:RadioButtonList ID="RbAccount" runat="server" cssClass="Request">
<asp:ListItem Value="update" Selected="True">Change existing account </asp:ListItem>
<asp:ListItem Value="deprovision">Remove an account </asp:ListItem>
<asp:ListItem Value="new" Enabled="false">Create a new account </asp:ListItem>

If i am using this css style, it is giving me border all all the tables i have on page, i just want only this radiobuttonlist, Any idea ?

<style type="text/css">
    border:1px solid black;

Need Help with Radiobuttonlist Style ASAP


How could is style the button or sort of icon into the gif image i wan

Example here is the CSS code
.radio {
width: 19px;
height: 25px;
padding: 0 5px 0 0;
background: url(checkbox.gif) no-repeat;
display: block;
clear: left;
float: left;

.radio {
background: url(radio.gif) no-repeat;

.select {
position: absolute;
width: 158px;
height: 21px;
padding: 0 24px 0 8px;
color: #fff;
font: 12px/21px arial,sans-serif;
background: url(select.gif) no-repeat;
overflow: hidden;

How could i call it in ASP to be used in
<asp:RadioButtonList ID="RadioButtonList3" style="position: relative" 
runat="server" AutoPostBack="true" 
OnSelectedIndexChanged="RadioButtonList3_SelectedIndexChanged" Height="26px" 
Width="208px" " BorderStyle="None" 

RadioButtonList in FormView EditTemplate's not me behind and OldValue NewValues


Hello people,

I am using FormView component which has a field that is the sex of the person that I am using RadioButtonList with a simple way to show Male and Female, but want to retrieve the information and OldValue NewValues not anything behind me.

In the FormView Edit Template:
" yc=""><! - SEX ->

Gender: " yc="Sexo:   " yc=""><td>
   'RepeatColumns = "2">     " yc="' RepeatColumns="2">"><Asp: RadioButtonList ID = "CHR_SEXORadioButtonList" runat = "server" SelectedValue ='<%# Eval ("CHR_SEXO")%> &#

jQuery radiobuttonlist

Hi,I'm trying to show/hide a div based on the selected value of radiobuttonlist using jQuery (1.3.2.min). I've tried a thousand different methods and can't get any of them to work :( I have the following code so far:<asp:RadioButtonList ID="rdbMeds" CssClass="assess" RepeatLayout="Flow" RepeatDirection="Horizontal" runat="server"> <asp:ListItem value="yes">Yes</asp:ListItem> <asp:ListItem value="no" Selected="true">No</asp:ListItem> </asp:RadioButtonList> <div id="rdbMeds_hid"> If yes, please specify what it is for: <asp:TextBox ID="tbMeds" CssClass="textboxnormal" runat="server" /> </div> And I have the following jQuery:$(document).ready(function(){$("#rdbMeds").change(function(){//If checkedif ($("#rdbMeds").attr(":checked")){//show the hidden div$("#rdbMeds_hid").show("fast");} else { //otherwise, hide it $("#rdbMeds_hid").hide("fast");}});});Any help would be much appreciated.

Binding RadioButtonList from Code Behind

I'm trying to populate my form that is made up of RadioButtonLists, a Text Box and a DropDown via Code Behind.  WHen I run it, the Text Box and the DropDown populate, but the RadioButtonLists do not.  I'm guessing it has to do with the SelectedValue command, but I'm not sure what to use.  Here is my aspx page:<ContentTemplate> <div style="height:402px;"> <br /> <table> <tr> <td colspan="2"> <p style="font-size:90%;">Here, you can set your preferences for notifications during the draft. You can change them at any time.</p> <p style="font-size:90%;">You will always be emailed if it is your turn to pick and you have no players in the Pick Queue.</p> </td> </tr> <th colspan="2"> Email Options </th> <tr> <td> Send

Getting Selected Item in radiobuttonlist on content page using javascript

I am trying get the selected value from a radiobuttonlist on a content page using javascript. Here is my initial code, which does not recognize the control. The js is located in a separate file and there is a link on the content page pointing to the js file. Thanks, function GetRadioButtonValue() { var radio = document.getElementsByName('<%=rblPayType.ClientID%>'); for (var j = 0; j < radio.length; j++) { if (radio[4].checked) { alert(); return; } else { return; } } }    

RadioButtonList without the Radio Button Circle?

basically, i just want the RadioButtonList without the radio button on it, i will code the rbl so that selected items have a different background color and make it look more professional, the radio buttons themselves i want to be able to get rid of in terms of apperance... if you know of any way to do it, please do let me know!

FormView control having radiobuttonList as child control which is bound to another datasource

Hi all, Mine is an Online Exam application. I am thinking to place the questions and answer options inside a formview control. As options are from different table ,so I wanted to use RadioButtonList as child control of FormViewControl to display options which is bound to another datasource .How can I do this please help.  

Bind SQL Data to a RadioButtonList

 Hi all, I need to bind data from an SQL Select Statement into a RadioButtonList and have not been able to come up with anything that works. <asp:Table runat="server" ID="TableTitle" Width="800px" CssClass="Table" Style="margin-top: 20px;"> <asp:TableHeaderRow runat="server"> <asp:TableHeaderCell runat="server" Font-Size="Medium" HorizontalAlign="Center" ColumnSpan="2">Title</asp:TableHeaderCell> </asp:TableHeaderRow> <%--Exam Questions--%> <asp:TableRow runat="server"> <asp:TableCell runat="server" HorizontalAlign="Left" Font-Bold="true" Text="Multiple Choice Question" ColumnSpan="2" /> </asp:TableRow> <asp:TableRow runat="server"> <asp:TableCell runat="server" HorizontalAlign="Left"> <asp:RadioButtonList ID="RadioButtonQ1" runat="server" RepeatDirection="Vertical" /> </asp:TableCell> </asp:TableRow> </asp:Table> In my VB code behind I have a select statement that retreives the information from the database and randomizes the answers, but I am unable to get t

Selected value of RadioButtonList inside a formview get cleared on button click.

Hi all,I placed a RadioButtonList inside a Formview control.And from  DataBound event handler of formview ,RadioButtonList is binded to the datasource .Now my problem is after selecting a value from radiobuttonlist and I click any button,the radiobuttonList get unchecked and lose the selected value .How can I avoid this.Please help..

how to save radiobuttonlist data into database when they are in disable position

hiiiiiam using 2 radio buttonlist controls in web application they are FIRST      Yes    NoSECOND  Yes    NoInitially  SECOND radio button list is in disable position.when i was click on yes of FIRST radio button list, then SECOND radio button list is enables otherwise it is in disable mode only.here my problem is when i am inserting data into the database the disable radio button list gives error as System.NullReferenceException: Object reference not set to an instance of an object.code written for inserting isprotected void Button1_Click(object sender, EventArgs e)    {                    SqlConnection con = new SqlConnection(@"Data Source=STS2\SQLEXPRESS;Initial Catalog=STS;Integrated Security=True");            string sql;            sql = "insert into Table1(";            sql += "First,Second)";            sql += "values('";            sql += rbl_first.SelectedItem.Value.ToString() + "&

RadioButtonList inside the GridView control

Hi, I have several rows inside the GridView control and each row contains a RadioButtonList control. I select the option c from the RadiobuttonList but when I press submit I always get the first index of the RadiobuttonList which is a). Hence, the RadiobutonList is not maintaining the selected positions. Any idea how to maintain the value.

how to give validation to a radiobuttonlist

 Hi all, Can anybody tell me how to give validation to a radiobuttonlist control to select atleast one radiobutton.It's urgent pls help me.

validating radiobuttonlist inside gridview


I am sure this has been asked before but I cannot find a solution to my problem. I have a radiobuttonlist inside an itemtemplate inside my gridview. It contains a list of items with yes or no options. What I need to do is make sure all items were selected either 'Yes' or 'No' when I click a button. If some our left blank I want to stop them from proceeding and give them a message that not all questions are answered. Any ideas about how I could go about this or a different way that would be easier.

<asp:GridView ID="GridView1" CssClass="tabletext" Width

Get asp.net radiobuttonlist selected value in code behind when using jQuery buttonset


I am using the jQueryUI buttonset on an ASP.NET radiobuttonlist. I need to get the selected value in server-side code when the page posts back. If I don't apply the jQuery buttonset, this is of course easy enough - just grab "SelectedValue". However, when I do apply jQuery buttonset, the selected value does not appear to be available on postback any longer. Is there any way around this, or do I need to get the selected value on clientside, and then pass it back myself?

<asp:RadioButtonList ID="RadioButtonList0" CssClass="ratingButtons" runat="server">
    <asp:ListItem Text="Option1" Value="1"/>
    <asp:ListItem Text="Option2" Value="2" />
    <asp:ListItem Text="Option" Value="3" />
    <asp:ListItem Text="Option4" Value="4" />

  $(function () {
      $(".ratingButtons").click(function () { return false; });


Radiobuttonlist SelectedIndexChanged When Changing dropdownlist



I have a radiobutton list that changes the contents of a dropdownlist when the selected radiobuttonlist index is changed using the SelectedIndexChanged event. Both controls are within the same updatepanel and both have autopostback set to true.

For some reason when I change the dropdownlist and cause a postback, the radiobuttonlist change event fires and repopulates the dropdownlist which effectively cancels the selection made in the dropdown.

I know something simple must be causing this behaviour but I cannot think what and my debugging efforts are not shedding any light thus far. I have tried putting a breakpoint on every procedure in my form and the first event that fires is the radiobuttonlist SelectedIndexChanged event so nothing in my server side code seems to be doing this which suggests it is something in the markup but I can't think what. 

Does anyone have any idea what may be causing this infuriating but obviously simple problem?



Populate RadiobuttonList from Database



I am using:

 If IsDBNull(ds.Tables("tblStateDocuments").Rows(0).Item("IsPublic")) Then


 DropDownList3.SelectedValue = varDocPublic

 Dim varDocPublic As String = (ds.Tables("tblStateDocuments").Rows(0).Item("IsPublic"))

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend