2014年7月13日 星期日

[RESOLVED] ImageButton: How to pass my value through command argument in c#?


ImageButton: How to pass my value through command argument in c#?


Hello,when i click one of them I want to pass values to ImageButton2_Click event But it does not work because Command arguments is null.

Why?





CommandArgument='<%# Eval("IDFoto")%>' Width="50px" Height="50px" Style="cursor: pointer"
OnClick="ImageButton2_Click" />





protected void ImageButton2_Click(object sender, EventArgs e)
{
guid = Guid.NewGuid();

ImageButton ImageButton2 = (ImageButton)sender;
idFoto = ImageButton2.CommandArgument;

Response.Redirect("default.aspx?myGUID=" + guid.ToString() + "&idFoto=" + idFoto.ToString() + "");

}



Have your tried:


idFoto = e.CommandArgument;


沒有留言:

張貼留言