本文介绍了插入数据后取消选中单选按钮。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,



我参与了一个asp项目。我需要你的小帮助。我的页面中有两个单选按钮,如YES&没有。所以在那种情况下,总是选择NO作为我的默认值,当我点击YES并在该单选按钮被选为NO后插入记录。我已将代码编写为



Dear sir,

i worked on a asp project. I need a small help from you. I have two radio button in my page as like YES & NO. So in that situation NO is always selected as my default value and when I clicked on YES and insert the record after that Radio button should selected as NO. I have written the code as

protected void btnSaveprint_Click(object sender, EventArgs e)
   {
   cmd.CommandText = "INSERT INTO tbl_healthrecord (sl_no,entry_date,factory_name,chkValue)
   values ('" + code + "','" + txtDateentry.Text + "','" + txtFactoryName.Text.ToUpper() + "','"+chk+"')";
cmd.Connection = con;
                cmd.ExecuteNonQuery();
                con.Close();
 rdbNo.Checked=true;
} 





但它不起作用。所以请告诉我一些解决方案。

谢谢&问候

Bigyan Ranjan Sahoo



But it does not work. So plz tell some solution for me.
Thanks & Regards
Bigyan Ranjan Sahoo

推荐答案

public void rdbData()
   {
       rdb_Yes.Checked = true;
       rdb_No.Checked = false;





}





}

protected void btnSaveprint_Click(object sender, EventArgs e)
   {

cmd.CommandText = "INSERT INTO tbl_healthrecord (sl_no,entry_date,factory_name,chkValue)
values ('" + code + "','" + txtDateentry.Text + "','" + txtFactoryName.Text.ToUpper() + "','"+chk+"')";
Collapse | Copy Code

cmd.Connection = con;
                cmd.ExecuteNonQuery();
                con.Close();



rdbData();
}


这篇关于插入数据后取消选中单选按钮。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 05:01