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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 27, 2013, 1:57 AM EDT
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