try like follows
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);
first see the definition for
Controls.Find
public Control[] Find(
string key,
bool searchAllChildren
)
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controlcollection.find(v=vs.100).aspx[
^]
suppose i=2
string.Format("lbl{0}", i)
give the value =lbl2
this.Controls.Find
search the controls by given key.
for ex:
after compiling the
this.Controls.Find(string.Format("lbl{0}", i), false).First().Text
it just like
this.Controls.Find("lbl2", false).First().Text
.First()
is a LINQ to select the first element.
forget to mentioned you may have to include the namespace
using System.Linq
;