Code as follows;
String Sql;
SqlDataReader Dr;
SqlDataCon Scon = new SqlDataCon();
Label1.Text = "";
try
{
if (CrsList.GetMajorCode.ToString().Trim() == null || CrsList.GetMajorCode.ToString().Trim() == "")
{
Label1.Text = "Invalid course. Course is not selected";
return;
}
if (CrsList.GetMinorCode.ToString().Trim() == null || CrsList.GetMinorCode.ToString().Trim() == "")
{
Label1.Text = "Invalid course. Course is not selected";
return;
}
if (CrsList.GetBatchDate.ToString().Trim() == null || CrsList.GetBatchDate.ToString().Trim() == "")
{
Label1.Text = "Invalid Batch. Batch is not selected";
return;
}
DataTable Dt = new DataTable();
Sql = "OH_BatchWise_Collection_Report_Psea'" + CrsList.GetBatchID.ToString().Trim() + "'";
Dr = Scon.ReadSql(Sql);
Dt.Load(Dr);
//Generating the excel
String attachment = "attachment; filename=collectiondetails.xls";
Response.ClearContent();
Response.ClearHeaders();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.Write("");
Response.Write("");
Response.Write("");
Response.Write("");
Response.Write("");
");
Response.Write("HIMT COLLEGE"); Response.Write(" | ");|||||||
Response.Write("Batch wise fee collection details- " + CrsList.GetMinorCode.ToString().Trim() + " - " + CrsList.GetBatchDate.ToString()); Response.Write(" | ");
Response.Write("");
");
Response.Write("");
Response.Write("");
//Response.End();
}
catch (Exception ex1)
{
Label1.Text = ex1.ToString();
return;
}
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (Exception ex1)
{
Label1.Text = ex1.ToString();
return;
}
Design page in run mode as follows;
Dropdownlist (All Course name is there)
Listbox1 Listbox2
In Listbox 1 all the sub course are present
In Listbox 2 batch date of sub course are present.
In the run mode when i select the course from the downlist, in the listbox1 subcourse are present and select the sub course from listbox1 then batchdate are present in the listbox2.
Then i click the Generate button that particular batch date of course want to show in the excel.
for that saving the data in the excel i written the code above.
But i click the Generate Button that particular batch date of course excel is not opening.
what is the problem in my above code.
from my above code what is the problem please help me.
Regards,
Rao
Replies
Know the answer? Post it — somebody with the same question will find it here.