Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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:
SQL
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(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
Posted
Updated 10-Aug-15 23:59pm
v2
Comments
Kornfeld Eliyahu Peter 11-Aug-15 4:10am    
Where are you checkboxes? Where is the code to bind to the event?
Andy Lanng 11-Aug-15 4:11am    
Your code dump makes no sense. Why post the event if it's not firing?
Q1: Does the method chkBoxListSpeciality_SelectedIndexChanged run?
Q2: If not, show us the markup for your checkboxs
Q3: If it does run then what is the issue?

Please explain the actual problem
Member 10978775 11-Aug-15 5:55am    
Actually i have a search like Find a doctor with speciality and location wise....
after entering specialty and locations the list of doctors are displaying in dataview .the left side of the result page remaining specializations are visible in a checkbox list for advanced search... like flipkart we can modify our search


<asp:CheckBoxList ID="chkBoxListSpeciality" runat="server" style="height:10%" OnSelectedIndexChanged="chkBoxListSpeciality_SelectedIndexChanged">

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900