I have a webform1 in which I have a sem.Text textbox. Here is the code to pass that
value to a second webform
private string semana_x;
public string semana
{
get
{
return semana_x;
}
set
{
semana_x = value;
this.sem.Text = value;
}
}
protectedvoid b_Click(object sender, EventArgs e)
{
Response.Redirect("webf2.aspx?semana=" + semana);
}
web form 2
//aqui recibo el valor del webf1 y lo convierto a int
int valor;
int.TryParse(Request.QueryString["semana"], out valor);
//para compararlo con un campo de BD
SqlCommand cmd = new SqlCommand("SELECT * from tabla where semana="+valor+",con);
//y mostrar todo en un gridview
SqlDataAdapter da = newSqlDataAdapter(cmd);
DataTable dt = newDataTable();
da.Fill(dt);
gridview1.Visible = true;
gridview1.DataSource = dt;
gridview1.DataBind();
con.Close();
}
the problem is that when I write the number in the texbox it doesn't show me anything in the table and my
link appears like this: localhost:49236/Project/webf2.aspx?week=
but if I add a number at the end
link like this: webf2.aspx?week=48<-- like this, and if it shows me the data in the gridview
I hope you can help me
Thank you
Cheers
For everything we talked about in the comments, the values entered in your webform are not being passed to your class.
Your property should be something like this:
Somewhere, you should load that value into that property. Just as an example, let's assume that we do it on click (something that doesn't make much sense, because if we do it there, let's send it directly)
You are thinking something wrong if you built the property the way you had built it. Review concepts about that.
You can also send it in one session and retrieve it in the next destination.