TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ajit N
NA
352
71.5k
How to Generate/Print Multiple StudentID from Datagridview ?
Jan 31 2017 6:53 AM
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...
//this code is used for passing 2 values to GenerateIDCard Form
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....
Reply
Answers (
1
)
How to pass an argument to cmd.exe ?
How to Validate the TextBox That Only Allows Letters & space