Hello Sir,
My name is Kanishka ,I generating admit card but i have some problem in that code
when i fill correct credential in textbox still it shows candidate not found.
Actually in this code , compiler does not consider if block , it compiles directly else condition and show the output "candidate not found ".
i am sending you my code. Please review it and give me some solution so that i can operate this code.
************************aspx code****************************************
.style1
{
text-align: center;
}
style="font-weight: 700" Width="304px"> | |
Width="304px"> | |
Text="Show" Width="176px" Font-Names="Bodoni MT Black" ForeColor="White" Font-Size="Medium" BackColor="#009933" BorderColor="#009933" /> | |
runat="server" style="color: #FF0000; font-weight: 700">
style="border-style: none; border-color: inherit; border-width: 0px;"> ???????: ?????? ?????? ???????: www.company.gov.in ????????? ?????: 25435348724 ???? ????: [email protected] | style="border-style: none; border-color: inherit; border-width: 0px;"> Logo | style="border-style: none; border-color: inherit; border-width: 0px;"> Company Name class="style8"> Area: South Delhi Website: www.company.gov.in class="style2"> HelpLine Number: 25435348724 |
style="border-style: none; border-color: inherit; border-width: 0px;"> ? ?????? ?????????? / E-admission Certificate ???????????? ?? ?? 2019 Post of Stenography 2019 | ||
style="border-style: none; border-color: inherit; border-width: 0px;">??????? ??????/Exam Time: 28/febuary/2019 | style="border-style: none; border-color: inherit; border-width: 0px;">??????? ???? ?? ???/Repoting Time 9:00AM | style="border-style: none; border-color: inherit; border-width: 0px;">?????? ??? ???? ?? ???/ Entry Closing Time: 10:00 A.M. |
| ????? ?? ???/ Name of Applicant's style="color: #FF0000"> | ???? /Gender ID="lbl_Gendar" runat="server" style="color: #FF0000"> | |
rowspan="2">??????? ?????? / Exam Center: style="color: #FF0000"> Address of that company | ??????/ Category | |
| ????????/ Date of Birth | ||
runat="server" Text="Print" Height="35px" Width="95px" Font-Names="Bodoni MT Black" ForeColor="White" Font-Size="Medium" BackColor="#009933" BorderColor="#009933" onclick="Button2_Click"> | ||
************************ C# Code *************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.IO;
using System.Configuration;
public partial class admiitcard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//Pnl_admit.Visible = true;
//Pnl_login.Visible = false;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
string strConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection myConnect = new SqlConnection(strConnectionString);
string strCommandText = "SELECT CandidateName, Gender, Category, DOB FROM admitcard where CandidateName = '" + txt_CandidateName + "' and FatherName = '" + txt_CFathersName + "'";
SqlCommand cmd = new SqlCommand(strCommandText, myConnect);
myConnect.Open();
// SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Pnl_admit.Visible = true;
// Label3.Text = "Data Found";
lbl_CandidateName.Text = txt_CandidateName.Text;
lbl_FatherName.Text = txt_CFathersName.Text;
lbl_ApplicantName.Text = ds.Tables[0].Rows[1]["CandidateName"].ToString();
lbl_Gendar.Text = ds.Tables[0].Rows[2]["Gender"].ToString();
lbl_category.Text = ds.Tables[0].Rows[3]["Category"].ToString();
lbl_DOB.Text = ds.Tables[0].Rows[4]["DOB"].ToString();
}
else
{
ErrorMsg.Text = "Candidate Not Found";
}
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=GridViewData.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Pnl_admit.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10, 10, 0, 0);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Salman BegPosted Feb 19, 2019, 12:07 AM