Modify CommandArgument from Code Behind

F

Fabrice

Hello

Is it possible to modify CommandArgument property of a LinkButton from vb
class (code behind).
So, this is my control in my .aspx page :

<asp:LinkButton id="strTd" OnCommand="lnkButtonClick"
enableviewstate="False" CssClass="Detail" Text="Text"
runat="server"></asp:LinkButton>

In my .vb class, i would like to modify the CommandArgument property in the
Sub Page_Load
For Example :

myvar =
Ctype(Server.HtmlEncode((Request.QueryString.GetValues("id")(0))),Integer)
strTd.CommandArgument=myvar .ToString()

But when i select my linkbutton i have the follow error

Format String is incorrect.

Can you help me ?

thanks
fabrice

--- Mesage !

Détails de l'exception: System.FormatException: Le format de la chaîne
d'entrée est incorrect.

Erreur source:

Une exception non gérée s'est produite lors de l'exécution de la demande Web
actuelle. Les informations relatives à l'origine et l'emplacement de
l'exception peuvent être identifiées en utilisant la trace de la pile
d'exception ci-dessous.

Trace de la pile:


[FormatException: Le format de la chaîne d'entrée est incorrect.]
Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value,
NumberFormatInfo NumberFormat) +195
Microsoft.VisualBasic.CompilerServices.IntegerType.FromString(String
Value) +97

[InvalidCastException: Cast de la chaîne "" en type 'Integer' non valide.]
Microsoft.VisualBasic.CompilerServices.IntegerType.FromString(String
Value) +212
Microsoft.VisualBasic.CompilerServices.IntegerType.FromObject(Object
Value) +750
BehindPatDetails1.lnkButtonClick(Object sender, CommandEventArgs e) +14
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +110
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1292
 
K

Karl Seguin

Fabrice:
Your error has nothing to do with setting the commandArgument

It seems that your ctype(XXX, integer) is invalid. In other words, whatever
the value is, can't be converted into an integer....

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top