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
elham deljooei
NA
84
73.1k
How to put a variable in the name of contorols, txt[i]?
Jan 25 2013 2:50 AM
Hi everyone
i have some Textboxes and lables. their names is txt1,txt2,...and lbl1,lbl2,.... I want to put 'i' rather than 1 ro 2... fro ex: lbl[i](=lbl1). i have to put i rather than 1 when i can send all lbl or txt . but when i run, in highlight line has this eeror "eeror Sequence contains no elements"
SqlCommand cmd = new SqlCommand("ClerkEvaluation_Insert", conn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i = 1; i <= 10; i++)
{
cmd.Parameters.AddWithValue("@clrk_Name", txtNameClerkEvaluation.Text);
cmd.Parameters.AddWithValue("@clrk_Family", txtFamilyClerkEvaluation.Text);
cmd.Parameters.AddWithValue("@clrk_MelliCode", txtMelliCodeClerkEvaluation.Text);
//cmd.Parameters.AddWithValue("@epcnt_Name", "?????");
//cmd.Parameters.AddWithValue("@clrke_Percent", lbl1MadrakeTahsili[i].Name.su
//cmd.Parameters.AddWithValue("@clrke_Tozihat", txtRaftar[i].);
cmd.Parameters.AddWithValue("@i", i);
MessageBox.Show(Convert.ToString(i));
cmd.Parameters.AddWithValue("@clrke_Percent", this.Controls.Find(string.Format("lbl{0}", i), false).First().Text);
cmd.Parameters.AddWithValue("@clrke_Percent", this.Controls.Find(string.Format("txt{0}", i), false).First().Text);
cmd.ExecuteNonQuery();
conn.Close();
Reply
Answers (
0
)
How to put a variable in the name of contorols, txt[i]?
How to put a variable in the name of contorols, txt[i]?