Filter is not working when post back event is used

Last Reply 8 days ago By dharmendr

Posted 12 days ago

 

<div>
Remarks:
<asp:DropDownList ID="ddlCountries" runat="server"
AutoPostBack="true" onselectedindexchanged="ddlCountries_SelectedIndexChanged">
<asp:ListItem Text="All" Value="" />
<asp:ListItem Text="Present" Value="Present" />
<asp:ListItem Text="Absent" Value="Absent" />
<asp:ListItem Text="Leave" Value="Leave" />

</asp:DropDownList>
<hr />
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
Height="1000" Width="1000" BestFitPage="True" ToolPanelView="None" />
</div>

 

public partial class rptAttendance : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
/*if (!this.IsPostBack)                             if I use this is did not show nothing
{                 
this.BindReport();
}*/
this.BindReport();                      //if use this then it does not filter the absent students
}



private void BindReport()
{
ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(Server.MapPath("~/rptAttendanceSTU.rpt"));
AttenDS dsCustomers = this.GetData(ddlCountries.SelectedItem.Value);
crystalReport.SetDataSource(dsCustomers);
CrystalReportViewer1.ReportSource = crystalReport;
}

private AttenDS GetData(string country)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlCommand cmd = new SqlCommand("SELECT AdmissionNo,ADate,Remarks FROM tblAttendance WHERE Remarks = @Country OR @Country = ''"))
{
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
cmd.Parameters.AddWithValue("@Country", country);
using (AttenDS dsCustomers = new AttenDS())
{
sda.Fill(dsCustomers, "AttenDT");
return dsCustomers;
}
}
}
}
}


protected void ddlCountries_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindReport();
}

hereby snapshot is attached

ufgsdgfhdsf

You are viewing reply posted by: smile 12 days ago.
Posted 12 days ago

irrelevent answer. U always provide wrong link to waste time. what a nonsense