473,782 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modify CommandArgument from Code Behind

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:LinkButt on id="strTd" OnCommand="lnkB uttonClick"
enableviewstate ="False" CssClass="Detai l" 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.Ht mlEncode((Reque st.QueryString. GetValues("id") (0))),Integer)
strTd.CommandAr gument=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.FormatEx ception: 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.Visua lBasic.Compiler Services.Double Type.Parse(Stri ng Value,
NumberFormatInf o NumberFormat) +195
Microsoft.Visua lBasic.Compiler Services.Intege rType.FromStrin g(String
Value) +97

[InvalidCastExce ption: Cast de la chaîne "" en type 'Integer' non valide.]
Microsoft.Visua lBasic.Compiler Services.Intege rType.FromStrin g(String
Value) +212
Microsoft.Visua lBasic.Compiler Services.Intege rType.FromObjec t(Object
Value) +750
BehindPatDetail s1.lnkButtonCli ck(Object sender, CommandEventArg s e) +14
System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e) +110
System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String
eventArgument) +115
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +138
System.Web.UI.P age.ProcessRequ estMain() +1292


Nov 19 '05 #1
1 3172
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******@spa m-infonie.fr> wrote in message
news:%2******** *******@TK2MSFT NGP09.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:LinkButt on id="strTd" OnCommand="lnkB uttonClick"
enableviewstate ="False" CssClass="Detai l" 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.Ht mlEncode((Reque st.QueryString. GetValues("id") (0))),Integer)
strTd.CommandAr gument=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.FormatEx ception: 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.Visua lBasic.Compiler Services.Double Type.Parse(Stri ng Value,
NumberFormatInf o NumberFormat) +195
Microsoft.Visua lBasic.Compiler Services.Intege rType.FromStrin g(String
Value) +97

[InvalidCastExce ption: Cast de la chaîne "" en type 'Integer' non valide.]
Microsoft.Visua lBasic.Compiler Services.Intege rType.FromStrin g(String
Value) +212
Microsoft.Visua lBasic.Compiler Services.Intege rType.FromObjec t(Object
Value) +750
BehindPatDetail s1.lnkButtonCli ck(Object sender, CommandEventArg s e) +14
System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e) +110

System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String
eventArgument) +115
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +138
System.Web.UI.P age.ProcessRequ estMain() +1292

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1735
by: SStory | last post by:
Doing pages for contract..... If I make an ASPX file that does certain things, how simple would it be for a person who know nothing about it to modify the user interface without bothering the ASPX interaction? How would I best build such pages. Many people of course don't want a page that they can't modify at all without programmer intervention. I think ASPX does this. Just curious to hear some comments on the subject from more...
0
1563
by: Solomon Shaffer | last post by:
I have a datagrid that I am adding a template column to (containing a couple of linkbuttons) at runtime and am having some difficulty setting the commandargument or the linkbuttons. Does anyone know the syntax to databind the commandargument to the row through code. I am assumning I use the DataBinder.Eval method but I cannot get it going. Below is the code sample. Thanks Solomon public class KnowlagentDataGridTemplate : ITemplate
2
2789
by: Liza | last post by:
Hi I have a problem gettting the right data in my CommandArgument after I applyed a rowfilter. My template column looks somewhat like this: <asp:TemplateColumn HeaderText="ErrorID"> <HeaderStyle Width="30%" CssClass="folderHeader"></HeaderStyle> <ItemTemplate>
2
4946
by: needin4mation | last post by:
I have some VB.NET code that I am trying to convert. I'm not sure what to do here and was hoping you could help. Sub PagerButtonClick(sender As Object, e As EventArgs) 'used by external paging UI Dim arg As String = sender.CommandArgument is the code from: http://www.4guysfromrolla.com/webtech/082901-1.2.shtml
2
6029
by: David | last post by:
I have a template field in a GridView that contains two ImageButtons. When the user clicks one of the buttons, the GridView's RowCommand event is fired and I can get the CommandName. All that is fine. However, e.CommandArgument is an empty string, presumably because the CommandArgument property of the ImageButtons is not set. Is there some way, in the markup, to set the CommandArgument to the row index? <ItemTemplate>
3
9453
by: Renilkumar | last post by:
I have a datagrid using link button. I am setting the CommandArgument value as .. <asp:linkbutton runat="server" EnableViewState=True CommandArgument='<%# DataBinder.Eval(Container.DataItem, "EmpId")%>' ....> In the .aspx.vb file I am referring this value as..
1
4609
by: Nathan Sokalski | last post by:
I am trying to set the CommandArgument property of a Button control from a template in a DataList of mine using code in the ItemDataBound event. However, it does not want to set the property (it is acting as if I did not set it). Here is my code that sets the CommandArgument property in the ItemDataBound event: CType(e.Item.FindControl("btnMainMoveDown"), Button).CommandArgument = CStr(CType(Me.datMain.DataSource,...
1
13308
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit ImageButton I needed to redirect the user to the Edit page where the data on the page would be prepopulated with data from the database. I tried several things without success then discovered that the CommandArgument property could be used for this...
1
2992
by: Leon Mayne | last post by:
Hello, I have a gridview that's bound to a generic list of business objects and am using the RowCommand event to capture user clicks on actions. This was working fine up until today, but now e.CommandArgument being passed into the RowCommand event handler is always coming back as an empty string and causing an invalid cast exception. The GridView itself has a hyperlink field to display the object name, and several TemplateFields to...
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.