愛生活 && 愛編程
最好用RadioButton,但如果用RadioButtonList1就的遍历一下,直接是无法取值的
[CODE]
private void LinkButton1_Click(object sender, System.EventArgs e)
{
string users=txtzhanghao.Text;
string pass=txtpass.Text;
string mail=txtmail.Text+DropDownList4.SelectedItem.Value;
string wenti=txtwen.Text;
string huida=txtda.Text;
string birth=DropDownList1.SelectedItem.Value+"-"+DropDownList2.SelectedItem.Value+"-"+DropDownList3.SelectedItem.Value;
for(int i=0;i<RadioButtonList1.Items.Count;i++)
{
if(RadioButtonList1.Items[i].Selected)
{
int sex=Convert.ToInt32("RadioButtonList1.Item[i].Value");
}
}
string sql="insert into zhuce(users,pass,sex,birth,mail,wenti,huida) values('"+users+"','"+pass+"','"+sex+"','"+birth+"','"+mail+"','"+wenti+"','"+huida+"')";
SqlConnection con=new SqlConnection("server=.;database=model;uid=sa;pwd=");
con.Open();
SqlCommand cmd=new SqlCommand(sql,con);
int i=cmd.ExecuteNonQuery();
if(i>0)
Response.Redirect("yes.aspx");
else
Response.Redirect("no.aspx");
}
[/CODE]