By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Modify CommandArgument from Code Behind

P: n/a
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.GetVa lues("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(Com mandEventArgs e) +110
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1292


Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Fabrice" <em******@spam-infonie.fr> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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.GetVa lues("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(Com mandEventArgs e) +110

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1292

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.