选中任何未触发的复选框项目事件时 [英] when selected any checkbox item event not fired

查看:71
本文介绍了选中任何未触发的复选框项目事件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void chkBoxListSpeciality_SelectedIndexChanged(object sender, EventArgs e)
    {
        pnlSpeciality.Visible = true;
        DataTable dt = new DataTable();       
            mycon.Open();
            if (chkBoxListSpeciality.SelectedValue != "")
            {
                SqlCommand cmd = new SqlCommand("GET_DOCTERDETAILS ", mycon);
                cmd.Parameters.AddWithValue("@spe", chkBoxListSpeciality.SelectedValue);
                cmd.Parameters.AddWithValue("@loc", txtloc.Text);
                cmd.Parameters.AddWithValue("@citid", ddlCity.SelectedItem.Text);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    lvDoctor.DataSource = dt;
                    lvDoctor.DataBind();
                    pnldoctimg.Visible = false;
                    pnlhome.Visible = false;
                    pnlslideimg.Visible = false;
                }

            }
            else
            {
                ShowAlertMessage("No Records Found");
            }
            mycon.Close();  
        
    }







存储过程:




Stored Procedure:

ALTER PROCEDURE [dbo].[GET_DOCTERDETAILS]
(
  @loc VARCHAR(30),
  @spe VARCHAR(50),
  @cityid VARCHAR(20)
)
AS
BEGIN
	
	SELECT a.doctorid, a.firstname+a.lastname as Name,b.spename,a.hospitalname,a.addr,a.imgpath,c.city 
	FROM tbl_DoctorReg a
	INNER JOIN tbl_spe b on b.speid=a.specialityid
	INNER JOIN tbl_loc l on l.locid=a.locid
	INNER JOIN tbl_city c ON c.cityid=l.cityid  
	WHERE l.loc LIKE @loc+'%' AND b.spename LIKE @spe+'%' AND c.cityid=@cityid	 
	
END







public void Bind_chkBoxListSpeciality()

{

mycon = new SqlConnection(ConfigurationM) anager.ConnectionStrings [con]。ConnectionString);

mycon.Open();

SqlCommand cmd = new SqlCommand(select * from tbl_spe,mycon);

SqlDataReader dr = cmd.ExecuteReader();

chkBoxListSpeciality.DataSource = dr;

chkBoxListSpeciality.Items.Clear();

chkBoxListSpeciality.DataTextField =spename;

chkBoxListSpeciality.DataValueField =speid;

chkBoxListSpeciality.DataBind();

mycon.Close();

}



这是我的CheckBoxList绑定方法,当用户搜索医生




public void Bind_chkBoxListSpeciality()
{
mycon = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
mycon.Open();
SqlCommand cmd = new SqlCommand("select * from tbl_spe", mycon);
SqlDataReader dr = cmd.ExecuteReader();
chkBoxListSpeciality.DataSource = dr;
chkBoxListSpeciality.Items.Clear();
chkBoxListSpeciality.DataTextField = "spename";
chkBoxListSpeciality.DataValueField = "speid";
chkBoxListSpeciality.DataBind();
mycon.Close();
}

This is my CheckBoxList Bind Method which is fired when user search for a doctor

推荐答案

啊 - 我看到了问题。



按钮可以使用提交行为。必须告知其他控件来实现它。



您需要将AutoPostback =True添加到列表控件。这将导致回发发生。



如果控件在UpdatePanel中,那么您可以将事件指定为部分回发触发器,否则您需要具有AutoPostback那里也是真实。



希望有所帮助^ _ ^

Andy
Ah - I see the problem.

Buttons can use "submit" behavior. Other controls must be told to implement this.

You need to add AutoPostback="True" to the list control. That will cause the postback to occur.

If the control is within an UpdatePanel, then you can specify the event as a partial postback trigger, otherwise you need to have AutoPostback="True" there as well.

Hope that helps ^_^
Andy


这篇关于选中任何未触发的复选框项目事件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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