问题描述
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
推荐答案
这篇关于选中任何未触发的复选框项目事件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!