I am working on desktop application. i tried some code for generating id and it will print only one Id at a time.
Now i want to print/generate multiple Id's based on Roll No from datagridview.
This is my code...
-
- int RollNo;
- string Class;
- private void btnGenerateID_Click(object sender, EventArgs e)
- {
- foreach (DataGridViewRow rw in dataGridView1.SelectedRows)
- {
- RollNo = Convert.ToInt32(rw.Cells[0].Value);
- Class = rw.Cells[2].Value.ToString();
- }
- GenerateIDCard generate = new GenerateIDCard(Roll, Class);
- generate.ShowDialog();
- }
and this code is used for getting this 2 values which passed from StudentReport Form
- int Getroll;
- string GetClass;
- public GenerateIDCard(int RollNo,string Class)
- {
- con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
- SqlConnection.ClearPool(con);
- con.Open();
- InitializeComponent();
- Getroll = RollNo;
- GetClass = Class;
- }
-
- public void GetStudentInfo()
- {
- SqlCommand cmd = new SqlCommand("select Sname,Class,DOB,Mobileno,Address,studimg from StudentRegister where Rollno='"+Getroll+"' and Class='" + GetClass + "'", con);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
-
- lblstudentname.Text = dr["Sname"].ToString();
- lblstudclass.Text = dr["Class"].ToString();
- lbldob.Text = DateTime.Parse(dr["DOB"].ToString()).ToString("dd-MMM-yy");
- lblstudentmobile.Text = dr["Mobileno"].ToString();
- lblstudentsaddress.Text = dr["Address"].ToString();
-
- Studentimage_picname = dr["studimg"].ToString();
- }
- dr.Close();
-
-
- studentpath = "E:\\CoachingClassImages\\StudentIDImages\\" + Studentimage_picname;
- pictureBoxstudent.Image = new Bitmap(studentpath);
- }
So help me how can i do this....