<%@ Page Language="C#" AutoEventWireup="true" CodeFile="radiolistadd.aspx.cs" Inherits="radiolist" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<h2 style=" color:blue; font-style:normal ">
How to ADD RadioButtonList Values
<br /> By Using Code in asp.net
</h2>
<div>
<div>
<asp:RadioButtonList
id="languageRadioButtonList"
runat="server"
OnSelectedIndexChanged="DropDownListSelectionChanged" >
</asp:RadioButtonList><br/>
<b><asp:label runat="server" id="favoriteLanguage" style="color:blue" /></b><br />
<asp:button ID="Button1" runat="server" Text="Submit" ForeColor="Blue"/>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class radiolist : System.Web.UI.Page
{
protected void Page_Load(object o, EventArgs e)
{
if (!IsPostBack)
{
ListItem item;
item = new ListItem("1", "HI");
languageRadioButtonList.Items.Add(item);
item = new ListItem("2", "HOW");
languageRadioButtonList.Items.Add(item);
item = new ListItem("3", "ARE");
languageRadioButtonList.Items.Add(item);
}
}
protected void DropDownListSelectionChanged(object o, EventArgs e)
{
favoriteLanguage.Text = "Selected Value:"+languageRadioButtonList.SelectedItem.Value;
}
}
No comments:
Post a Comment