hello sir i m having 4 radio buttons on default2.aspx page
on the same page i m using a database
it's columns are uname and status
whenever the user clicks on the radiobutton the status of that name should increment by 1(counter variable).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
int c = 0;
int d = 0;
int k = 0;
int f = 0;
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Text == "Krishna")
{
//Label1.Text=RadioButton1.Text;
c++;
SqlCommand cmd = new SqlCommand("update detail set status='"+c.ToString()+"' where uname='"+"Krishna"+"'",con);
cmd.ExecuteNonQuery();
con.Close();
}
else if (RadioButton1.Text == "Amit")
{
//Label1.Text = RadioButton1.Text;
d++;
SqlCommand cmd = new SqlCommand("update detail set status='" + d.ToString() + "' where uname='" + "Amit" + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}
else if (RadioButton1.Text == "Deelip")
{
//Label1.Text = RadioButton1.Text;
k++;
SqlCommand cmd = new SqlCommand("update detail set status='" + k.ToString() + "' where uname='" + "Deelip" + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}
else
{
//Label1.Text = RadioButton1.Text;
f++;
SqlCommand cmd = new SqlCommand("update detail set status='" + f.ToString() + "' where uname='" + "Yash" + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}
}
}