TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akhilesh Patel
NA
10
22.5k
ASP.NET RADIOBUTTON CONTROLS
Jan 13 2012 8:24 AM
Hi.......All.
I'm new and working on a project and I'm want to insert radio buttons values into database through c#
here is the code of Unit.aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Unit.aspx.cs" Inherits="Unit" %>
<!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></title>
<style type="text/css">
.style1
{
height: 28px;
}
</style>
<script runat="server">
protected void radiobutton_checkedchange(object sender, System.EventArgs e)
{
if (RB1.Checked == true)
{
Label1.Text = "You select Yes";
}
else
{
Label1.Text = "Please select Yes or No.";
}
if (RB2.Checked == true)
{
Label1.Text = "You select No";
}
else
{
Label1.Text = "Please select Yes or No.";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table border="1" width="1241" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2" bgcolor="#008000"> <br>
<font face="Arial" size="4" color="#FFFFFF">Stores & Inventory Management
System</font><br>
<br>
<br>
<br>
<br>
</td>
</tr>
<tr>
<td width="260" bgcolor="#008000" height="25" colspan="7"><b>
<font color="#FFFFFF" face="Arial" size="4">Unit Master Entry</font></b></td>
</tr>
<tr>
<td bgcolor="#008000" class="style2">Unit's Name</td>
<td bgcolor="#008000" width="975" class="style1">
<asp:TextBox ID="T1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td bgcolor="#008000" class="style2">C Date </td>
<td bgcolor="#008000" width="975" class="style1">
<asp:TextBox ID="T2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td bgcolor="#008000" class="style2">C Client</td>
<td bgcolor="#008000" width="975" class="style1">
<asp:TextBox ID="T3" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td bgcolor="#008000" class="style2">M Date</td>
<td bgcolor="#008000" width="975" class="style1">
<asp:TextBox ID="T4" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td bgcolor="#008000" class="style1">M Client</td>
<td bgcolor="#008000" width="975" class="style1">
<asp:TextBox ID="T5" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td bgcolor="#008000" class="style2">Is Activate</td>
<td bgcolor="#008000" width="975" class="style1">
<asp:RadioButton ID="RB1" runat="server" Text="Yes"
oncheckedchanged="RB1_CheckedChanged" AutoPostBack="True" GroupName="x" />
<asp:RadioButton ID="RB2" runat="server" Text="No"
oncheckedchanged="RB2_CheckedChanged" AutoPostBack="True" GroupName="x"/>
</td>
</tr>
<tr>
<td bgcolor="#008000" class="style2">
<td width="975" bgcolor="#008000">
<asp:Button ID="B1" runat="server" Text="Save" onclick="B1_Click" />
<asp:Button ID="B2" runat="server" Text="Reset" onclick="B2_Click" />
</td>
</td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#008000">
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#008000">
<font face="Arial" size="4" color="#FFFFFF">Demo
Version 1.0<br>
Copy Right, All Right Reserved 2011</font></td>
</tr>
</table>
</form>
</body>
</html>
and Unit.aspx.cs source code...........
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;
public partial class Unit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void B1_Click(object sender, EventArgs e)
{
string conn = "Data Source=SVPSL-PC; Initial Catalog=SUNBEAMSCHOOL; User Id=sa; Password=sa@1234;";
SqlConnection con = new SqlConnection(conn);
con.Open();
string str;
if(RB1.Checked==true)
{
str = Convert.ToString(1);
}
else
if(RB2.Checked==true)
{
str = Convert.ToString(0);
}
string qur = "Insert into SS_Mst_Unit(UnitName,IsActive,CDate,CUser,MDate,MUser) values('" + T1.Text + "','" + T2.Text + "','" + T3.Text + "','" + T4.Text + "','" + T5.Text + "')";
SqlCommand cmd = new SqlCommand(qur, con);
cmd.ExecuteNonQuery();
con.Close();
}
private string BitConverter(string str)
{
throw new NotImplementedException();
}
protected void B2_Click(object sender, EventArgs e)
{
T1.Text = "";
T2.Text = "";
T3.Text = "";
T4.Text = "";
T5.Text = "";
//T6.Text = "";
RB1.Checked = false;
RB2.Checked = false;
}
protected void RB1_CheckedChanged(object sender, EventArgs e)
{
}
protected void RB2_CheckedChanged(object sender, EventArgs e)
{
}
}
Please help me ............thanks......
Reply
Answers (
3
)
Mysql insert stored procedures
How to read and write a sound file?