I have webmethod which is static and i want to assign the value to text box using webmehod as shown below:
public static void Test(DataRow dr)
{
lblrollno.Text = Convert.ToString(dr[0]);
lblname.Text = Convert.ToString(1);
.
.
.
.
.
.
.
.
.
.
}
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Jul 27, 2013, 5:57 AM
You can't access non-static filed inside a static method. You can pass the field as a parameter and assign the value like this
Test(dr,lblrollno,lblname);
public static void Test(DataRow dr,Label lbl1,Label lbl2)
{
lbl1.Text=Convert.ToString(dr[0]);
lbl2.Text=Convert.ToString(dr[1]);
}
Regards,
Iftikar