I have the following code behind:
public partial class _Default : System.Web.UI.Page
{
List<GlassesCollection> gc= BL.Example.GetCategory() ;
protected void Page_Load(object sender, EventArgs e)
{
rpt1.DataSource = gc;
rpt1.DataBind();
}
protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Button btn = (Button)e.Item.FindControl("btn1");
btn.CommandArgument = DataBinder.Eval(e.Item.DataItem,"CollectionID").ToString();
}
}
I want to pass the content of the btn.CommandArgument to Label’s event that placed in another ASPX.CS file.
Is there any way to implement this?
Thank you in advance!
You can use QueryStrings. For example, your url will can look like:
Then, in your
somepage.aspx, you can have:If there’s a chance that the text might not be suitable for passing in a URL, you can encode it with HttpServerUtility.UrlEncode and then decode it with HttpServerUtility.UrlDecode before assigning it to the label.