S
Stan SR
Hi,
I need to understand a basic process.
I generate dynamic linkbuttons like
public int PageIndex
{
get
{
if (ViewStage["pg"]==null)
return 0;
else
return Convert.ToInt32(ViewState["pg"].ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
// I change my code for this post
myLabel.Text = PageIndex.ToString();
}
protected void addLink()
{
for (int i=0;i<3;i++){
myButton=new LinkButton();
myButton.CommandName="MyCommand";
myButton.CommandArgument+=new
System.UI.WebControls.CommandEventHandler(MyButton_Click);
myButton.Text="Page " + Convert.ToString(i+1);
}
}
protected void MyButton_Click(object sender, CommandEventArgs e)
{
ViewState["pg"]=e.CommandArgument.ToString();
}
My problem, I suppose it's very simple to find the issue, is when I click a
linkbutton, the Label is not updated (I need to click a second time to have
the right previous value).
I m not sure that I m clear (due to my poor english).
In fact I need to use this code to add it inside an UpdatePanel.
I thank you in advance for your help
Stan
I need to understand a basic process.
I generate dynamic linkbuttons like
public int PageIndex
{
get
{
if (ViewStage["pg"]==null)
return 0;
else
return Convert.ToInt32(ViewState["pg"].ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
// I change my code for this post
myLabel.Text = PageIndex.ToString();
}
protected void addLink()
{
for (int i=0;i<3;i++){
myButton=new LinkButton();
myButton.CommandName="MyCommand";
myButton.CommandArgument+=new
System.UI.WebControls.CommandEventHandler(MyButton_Click);
myButton.Text="Page " + Convert.ToString(i+1);
}
}
protected void MyButton_Click(object sender, CommandEventArgs e)
{
ViewState["pg"]=e.CommandArgument.ToString();
}
My problem, I suppose it's very simple to find the issue, is when I click a
linkbutton, the Label is not updated (I need to click a second time to have
the right previous value).
I m not sure that I m clear (due to my poor english).
In fact I need to use this code to add it inside an UpdatePanel.
I thank you in advance for your help
Stan