webForumDet fria alternativet

CommandArgument

1 svar · 157 visningar · startad av icaaq

icaaqMedlem sedan okt. 20004 910 inlägg
#1

Jag har en imagebutton som jag vill koppla ett ID till och tänkte då använda denna

[red]editButton.CommandArgument = Request.Params["id"].ToString();[/red]

För att sedan fånga upp värdet så här

[red]
Line 99: 		private void editButton_Click(object sender, System.Web.UI.ImageClickEventArgs e)
Line 100:		{
Line 101:			error.Text = ((LinkButton)sender).CommandArgument;
Line 102:		}[/red]

Men jag får följande felmess

[red]
 Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.[/red]

hur kan jag lösa detta?

mvh icaaq

icaaqMedlem sedan okt. 20004 910 inlägg
#2

Det är ju ingen LinkButton som jag använder utan en ImageButton så jag skulle använda

[red]
error.Text = ((ImageButton)sender).CommandArgument.ToString();
[/red]

mvh icaaq

125 ms totalt · 3 externa anrop · cache AV · v20260731051352-full.56cc9887
0 ms — hämta statistik (cache)
0 ms — hämta forumlista (cache)
122 ms — hämta tråd, inlägg och bilagor (db)