I have imported file from excel to gridview
BarCode AdmissionNo RefNo SName FName
and my code is
<asp:GridView ID="GridView1" runat="server" Class="table table-striped table-bordered table-hover">
</asp:GridView>
also save this data with the help of this code
protected void Insert(object sender, EventArgs e)
{
try
{
string filePath = string.Empty;
string contenttype = string.Empty;
string filename = string.Empty;
byte[] bytes = null;
filename = "photo.png";
contenttype = "image/png";
System.Drawing.Image defaultImage = System.Drawing.Image.FromFile(Server.MapPath("~/Images/photo.png"));
using (MemoryStream ms = new MemoryStream())
{
defaultImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
bytes = ms.ToArray();
}
con = new SqlDbConnect();
foreach (GridViewRow row in GridView1.Rows)
{
con.SqlQuery("INSERT INTO tblStdReg (AdmissionNo,ReferenceNo,AdmissionDate,YearID,CourseID,ClassID,SectionID,RollNo,SName,DOB,Gender,BloodGroup,Religion,SCNIC,SPhone,ParentID,FCNIC,FName,FPhone,FJob,MName,MCNIC,MPhone,MJob,Address,GuardianName,GCNIC,GPhone,GAddress,Qualification,Income,Email,BookNo,BookID,BookDate,SPic,SPicName,ContentType) VALUES (@AdNo,@RefNo,@AdDate,@YId,@CId,@ClId,@SId,@Roll,@SN,@dob,@Gen,@BG,@Rel,@SCNIC,@Ph,@PId,@FC,@FN,@FPhone,@FJob,@MN,@MCNIC,@MPhone,@MJob,@Add,@GuardianName,@GCNIC,@GPhone,@GAdd,@Qualification,@Income,@Email,@BookNo,@BookID,@BookDate,@SPic,@SPicName,@ContentType)");
con.Cmd.Parameters.AddWithValue("@AdNo", row.Cells[0].Text);
con.Cmd.Parameters.AddWithValue("@RefNo", row.Cells[1].Text);
con.Cmd.Parameters.AddWithValue("@AdDate", row.Cells[2].Text);
con.Cmd.Parameters.AddWithValue("@YId", row.Cells[3].Text);
con.Cmd.Parameters.Add("@SPic", SqlDbType.Binary).Value = bytes;
con.Cmd.Parameters.Add("@SPicName", SqlDbType.VarChar).Value = filename;
con.Cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value = contenttype;
con.NonQueryEx();
}
con.conClose();
ShowMessage("Students Details Imported Successfully...");
GridView1.Visible = false;
}
catch (Exception ex)
{
ShowMessage(ex.Message);
}
}
Now I want to generate and save Barcode based on AdmissionNo. Barcode should be generate automatically according to AdmissionNo inside gridview before saving each row. how to do it pls