如何从单选按钮选择的索引中检索chkbox的值? [英] How to retrieve value of chkbox from radio button selected index ?

查看:125
本文介绍了如何从单选按钮选择的索引中检索chkbox的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从单选按钮选择的索引中检索chkbox的值??

代码是:

Hi,

How to retrieve value of chkbox from radio button selected index ??

CODE IS :

<asp:DropDownList ID="ddSr" runat="server" AutoPostBack="true"
          EnableTheming="True" Height="16px"
          onselectedindexchanged="ddSr_SelectedIndexChanged" Width="190px">
      </asp:DropDownList>

<asp:RadioButtonList ID="rdoSr" runat="server" AutoPostBack="True"
                          onselectedindexchanged="rdoSr_SelectedIndexChanged">
          </asp:RadioButtonList>





protected void rdoSr_SelectedIndexChanged(object sender, EventArgs e)
    {

        SqlConnection conn = new SqlConnection(ConnString);
        SqlCommand cmd = new SqlCommand("Customer_FullJoin_State_Retrieve", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@SNo", rdoSr.SelectedItem.Value);


        conn.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        reader.Read();
        {
//Error Showing Here
            chkSr.SelectedItem.Value = reader["State"].ToString();  


            reader.Close();
        }
        conn.Close();
    }





ALTER procedure [dbo].[Customer_FullJoin_State_Retrieve]
@SNo int
as
select Customer.City AS City1,State.City AS City2,Customer.Sr_No as Sr_No1, * from Customer full Join State on Customer.City = State.City
where Customer.Sr_No=@SNo
RETURN



谢谢.



Thanks.

推荐答案

如果您只想要控件,请执行以下操作:

If you just want the control, do this:

RadioButtonList rbl = sender as RadioButtonList;
RadioButtonIterm item = rbl.SelectedItem;



如果需要项目的文本,请添加值"属性:



If you want the text of the item., add the Value propetrty:

string text = rbl.SelectedItem.Value;



如果您想要项目的索引,请执行以下操作:



If you want the index of the item, do this:

int index = rbl.SelectedIndex;


这篇关于如何从单选按钮选择的索引中检索chkbox的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆