Hi,
I am having trouble getting querystrings to show up in textboxes in a formview control. I know you have to dig deeper to find the textboxes, but I thought I had done so, but it doesnt seem to work at the moment..
I am currently getting:
'Buyers_Shippingdetails' does not contain a definition for 'SellerusernameTextBox'
referring to:
Line 28: this.SellerusernameTextBox.Text = Request.QueryString["sellername"];
as an error.. my code is:
protected void FormView1_Load(object sender, EventArgs e)
{
TextBox SellerusernameTextBox = FormView1.FindControl("SellerusernameTextBox") as TextBox;
TextBox NameitemTextBox = FormView1.FindControl("NameitemTextBox") as TextBox;
TextBox prodIDTextBox = FormView1.FindControl("prodIDTextBox") as TextBox;
this.SellerusernameTextBox.Text = Request.QueryString["sellername"];
this.NameitemTextBox.Text = Request.QueryString["itemname"];
this.prodIDTextBox.Text = Request.QueryString["proID"];
}
}
Thanks if someone can help! I am stuck with the same problem on a couple of pages.
Any advice is welcome!
Cheers,
Jon
First off, remove the "this" qualifier from in fron tof your variables. These are method-level variables and don't require qualifiers. Also, I'd recommend you move your code to the FormView.DataBound event.
protected void FormView1_DataBound(object sender, EventArgs e){TextBox SellerusernameTextBox = FormView1.FindControl("SellerusernameTextBox")as TextBox;TextBox NameitemTextBox = FormView1.FindControl("NameitemTextBox")as TextBox;TextBox prodIDTextBox = FormView1.FindControl("prodIDTextBox")as TextBox;if (SellerusernameTextBox ==null) {return; }if (NameitemTextBox ==null) {return; }if (prodIDTextBox ==null) {return; }SellerusernameTextBox.Text = Request.QueryString["sellername"];NameitemTextBox.Text = Request.QueryString["itemname"];prodIDTextBox.Text = Request.QueryString["proID"];}
Just the trick.
Thanks alot, as always.
Jon
0 comments:
Post a Comment