I have a dropdown list containing values
ValueA
ValueB
Required output
When I select the valueA or any value from dropdown list it should display data in Gridview without page refresh. I wrote the following code
HTML
<div class="col-sm-3">
<asp:UpdatePanel ID="SCPanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<label class="control-label" style="margin-top: 10px;">Branch</label>
<asp:DropDownList ID="ddlBranch" runat="server" class="validate[required] form-control"
AutoPostBack="True" OnSelectedIndexChanged="ddlBranch_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
protected void ddlBranch_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindSection();
}
protected void BindSection()
{
GridView1.Visible = true;
con = new SqlDbConnect();
con.SqlQuery("select AdmissionNo,RollNo,ClassName,SectionName,SName,FName,DOB,SPic from tblStdReg as sr inner join tblDefClass as dc on sr.ClassID=dc.ClassID inner join tblDefSection as ds on sr.SectionID=ds.SectionID where sr.ClassId=@CId and sr.SectionId=@SId order by RollNo, AdmissionNo");
con.Cmd.Parameters.Add(new SqlParameter("@CId", this.ddlClass.SelectedValue));
con.Cmd.Parameters.Add(new SqlParameter("@SId", this.ddlSection.SelectedValue));
adapt.SelectCommand = con.Cmd;
adapt.Fill(sTable);
if (sTable.Rows.Count > 0)
{
GridView1.Visible = true;
GridView1.DataSource = sTable;
GridView1.DataBind();
lblTotal.Text = GridView1.Rows.Count.ToString();
}
else
{
GridView1.Visible = false;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('No Record Found');", true);
lblTotal.Text = "0";
return;
}
con.conClose();
}
but nothing happened or it is showing nothing. How to get solution plz