Forms Data Controls :: Passing A Value To An ImageButton CommandArgument?

Nov 23, 2010

For a given MS SQL Database table of staff members, I'm using ASP to display each record line by line as follows:

So I've added 2 ImageButtons in an extra column and the problem I have is passing the record id as a CommandArgument to redirect to a secure page where the record can be edited or deleted.

Here's some code:



ctdRdr(0) evaluates to the ID value for the the record. )

When I click on the 'Delete' ImageButton the URL in the Response.Redirect becomes:


instead of, say:


I'm assuming that a <%= expression %> cannot be used to set a control parameter, but how else can I do it?

View 5 Replies

Similar Messages:

Web Forms :: Setting ImageButton CommandArgument From Foreach Loop?

Mar 10, 2010

I have a ImageButton in a for loop


How do I set the CommandArgument? The above code does not work and how to do this.

View 1 Replies

C# - ImageButton CommandArgument Doesn't Work.

Jul 13, 2010

Im trying to use ImageButton to link to another page. ImageButton is inside a Repeater and the code is following:

<ul id = "ulMap">
<asp:Repeater ID="Repeater1" runat="server" >
<asp:ImageButton ID="ImageButton1"
CommandArgument='<%#Eval("Nav_ID") %>'

View 3 Replies

C# - Passing Two Values Through CommandArgument And Splitting It?

Dec 7, 2010

I'm using the commandArgument property of the LinkButton ( Which is wrapped inside a repeater ) to pass two values -as one string- to a second repeater then I try to split them into two values, So I could use them as parameters in my ADO.NET Code (SqlCommand Parameters)....after testing my queries don't return any results but If I passed fixed values for the parameter or change the source of the parameter (just for test from a textbox or querystring or something) I get my results, so I think the problem is in splitting.

I Conduct some arugment values from the ArgumentCommand property of the LinkButton -which is wrapped inside a repeater:

<asp:LinkButton id="sort_lnkbtn" Text='<%# Eval("value")%>'
CommandArgument='<%#string.Format("{0}|{1}",Eval("arrange_by_id"),Eval("value"))%>' runat="server">

Then I receive these values and cut them into two pieces of information:

string sortByAndArrangeBy = (e.CommandArgument).ToString();
char[] separator = { '|' };
string[] sortByAndArrangeByArray = sortByAndArrangeBy.Split(separator);

Now the code uses this values as a

using (SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
using (SqlCommand cm1 = new SqlCommand("SELECT [name] FROM brands WHERE (name like @SearchString + '%' )", cn1))
cm1.Parameters.Add("@SearchString", System.Data.SqlDbType.Char);
cm1.Parameters["@SearchString"].Value = sortByAndArrangeByArray[1];
using (SqlDataReader dr1 = cm1.ExecuteReader())
List_rpt.DataSource = dr1;

View 1 Replies

Gridview - Passing Multiple Argument Through CommandArgument Of Button?

Mar 5, 2010

I have a gridview with multiple rows, each has a Update button and I need to pass 2 values when someone clicks on Update button. Aside from packing the arguments inside CommandArgument separated by commas (archaic and not elegant), how would I pass more than one argument?

<asp:LinkButton ID="UpdateButton" runat="server" CommandName="UpdateRow" CommandArgument="arg_value" Text="Update and Insert" OnCommand="CommandButton_Click" ></asp:LinkButton>

As a note, the values can't be retrieved from any controls on the page, so don't offer any design solutions. Please concentrate on the question asked.

View 2 Replies

Forms Data Controls :: Commandargument And Checkbox In Gridview?

Feb 10, 2011

can i add commandname or commandargument to a checkbox-control in a gridview?

View 5 Replies

Forms Data Controls :: How To Read CommandArgument From ListView With InsertItemTemplate

Jun 7, 2010

I have a ListView and I'm using the option <InsertItemTemplate>. Inside this template I have two control: TextBox and Button.

I'm having tourble in C# to read the CommandArgument of my button OnCommand event:

What am I doing wrong?

protected void AddComment(object sender , CommandEventArgs e)
string Args = e.CommandArgument.ToString();

View 8 Replies

Forms Data Controls :: Calling CommandArgument Gives Empty String?

Mar 14, 2011

I have a button inside a table in gridview templatefield and i want to access its row index value in row_command event

i used this line.

Dim index As Integer = Convert.ToInt32(e.CommandArgument)

but got error .Input string was not in a correct format.

However i am able to fetch the row index value in button _click event using this line.

Dim index As Integer = (CType(CType(sender, Control).Parent.Parent, GridViewRow)).RowIndex

View 11 Replies

Forms Data Controls :: Gridview OnRowCommand Event GridViewCommandEventArgs E.CommandArgument Not Int?

Jan 20, 2011

I have a gridview and I have a link button that fires the onrowcommand event. In the method I have

protected void SelectCreditCard(object sender, GridViewCommandEventArgs e)
int index = Convert.ToInt32(e.CommandArgument);

But I get the error input string in incorrect format.

View 5 Replies

Forms Data Controls :: Ajax Accordion, ListView, LinkButton CommandArgument?

Jan 11, 2010

It becomes more and more complicated, how can I access the commandArgument of a LinkButton inside a ListView that is in a Accordion control?

View 5 Replies

Forms Data Controls :: GridView PageIndexChanging And RowCommand Not Returning E.CommandArgument

Dec 1, 2010

I have GridView in UserControl (ascx) who is in another ascx.


View 2 Replies

Forms Data Controls :: Commandargument Wouldn't Change For Session As Long As I Didn't Refresh The Gridview?

Jan 29, 2010

I have a gridview set up as follows:


Now, as you can see I've set up the commandargument, and was expecting to get to that in my code behind file. My code is as follows:

[Code].... far so good, and as long as I'm the only one working on the system it works fine. The problem is if this scenario happens:

* I go to the page and look at the gridview

* Someone else enters a new record into the database, causing the first row to contain a new record (not displayed in my browser)

* I click select.

What happens then is that, for some odd reason, I will get n numbers higher than the one I actually selected (n = num_added -num_removed).

I was under the impression that the commandargument wouldn't change for my session as long as I didn't refresh the gridview...?... There are no ajax or anything else messing with postbacks or viewstate as far as I can see..

View 5 Replies

Data Controls :: How To Bind Single Character To CommandArgument Of LinkButton

May 7, 2015

I want to pass single character passed when i clicked in the linkbutton.

and how i access this at code behind file.

View 1 Replies

C# - Passing Multiple Command Arguments In An ImageButton Control?

Mar 11, 2011

I'm designing a sort of hierarchical system, as follows:

Master Commodity

Each one of these are on their own page (for now). The user starts out on the Contract.aspx page. If they want to see the Master Commodities for the contract they are currently on, they will click the "ImageButton" I have set up, and I pass in as a command argument the ContractID (CommandArgument='<%# Eval("ContractID")%>'). This works great- I get to my Master Commodity page with the Master Commodities filtered on the ContractID I passed in.

Here's my problem: Navigating from the Master Commodity page to the Commodity page will (I think) require passing in the ContractID (so we JUST see stuff for the contract we're on), AND the Master Commodity ID (so we JUST see the Commodities that are related to the Master Commodity). I've tried the following: CommandArgument='<%# Eval("ContractID") + ',' + Eval("MComID")%>', but as you could probably expect, that doesn't work. If I can just do something like above and have a delimiter like the comma, I can go from there and make it work.

View 2 Replies

Forms Data Controls :: ImageButton In Datalist?

Sep 6, 2010

I have the following ImageButton which is a shopping cart I try to pass as parameter the product code when you click PostBackUrl.


It appears to me the following error when I click:System.Web.HttpException: A Potentially Dangerous Was Request.Path value detected from the client (&).Try not to validate the request: ValidateRequest = "false" but did not workYou know I could do to solve this problem?

View 4 Replies

Forms Data Controls :: Add Imagebutton In Datagrid Dynamically?

Nov 3, 2010

How can i add an imagebutton in my datagrid dynamically using vb codes.

View 3 Replies

Forms Data Controls :: Get Imageurl From First Imagebutton In Gridview?

Feb 21, 2010

I have a gridview containing a template field. The templated field is an image button. In code behind (page load event) I want to get the imageurl from the first imagebutton in my grid.

View 1 Replies

Forms Data Controls :: Manually Add ImageButton In GridviewColumn?

Jun 16, 2010

I got a data like this :


when I bind it into gridview, i want it to be like this:


View 5 Replies

Forms Data Controls :: Delete Imagebutton Not Working?

Apr 22, 2010

I've got a gridview with a SQLdatasource in my page which works fine. I used Imagebuttons for editing and deleting rows. After I implemented code (behind with RowDataBound) to make editing via rowselection possible (which workes fine), I also added code for my delete imagebutton to prohibit the detailsview when clicking the deletebutton:

<asp:ImageButton ImageUrl="" SkinID="ImageDelete" runat="server" ID="ImageDelete" CommandName="Delete" CommandArgument='<%# Eval("recordID") %>' OnClientClick="event.cancelBubble=true;return confirm('are you sure you want to delete?');" />

But now when I clcik the deletebutton, nothing is deleted. When I remove event.cancelBubble=true; it works fine.

View 8 Replies

Forms Data Controls :: ImageButton In TemplatePagerField In PageTemp(ListView)?

May 23, 2010

i have a pb im using listview which is datasource is datatable so im handling paging issue manually and i found abig pb the pagertemplate is working good for linkbutton but not for imagebutton .. cant use absolute postion cuz it gets bad look when i put it

View 2 Replies

Forms Data Controls :: Access ImageButton Inside ListView?

Jul 19, 2010

see the following code. How do I access the imageButton (or any other control I may happen to have) within the listView? In this case, I'd like to change the image of the imagebutton based on certain conditions in the code behind file while the listview is being populated.


View 3 Replies

Forms Data Controls :: Toggling Imagebutton Visibility Within A FormView?

Jul 9, 2010

I have a checkbox in a formview in "edit" mode. I want the check to fire an event and toggle a different command imagebutton based on the state of the checkbox. It doesn't seem to be working.

Heres my code.

My Checkbox with oncheckedchanged event


My two image buttons one visible one not visible on intial state


My event subrouting that toggles the button inside of the Formview1


View 6 Replies

Forms Data Controls :: Imagebutton Not Triggering GridView SelectedIndexChanged?

Jan 12, 2011

I am having an issue with using a GridView template that contains an imagebutton control. my current ASP code is as follows:


View 3 Replies

Forms Data Controls :: ImageButton - Changes Size Of The Image Applied?

Oct 12, 2010

I've created an image for my imageButton, but when applied, it renders using a different size to the original, making it display smaller than the original??

View 4 Replies

Forms Data Controls :: Update Using Imagebutton Click Within Gridview?

Mar 2, 2010

I have a gridview that has a column with an imagebutton. That image button event calls my update procedure and merely updates that records status and when the gridview rebinds, the image changes and is no longer available.Whats happening is if the page is refreshed, the update occurs again. If i add this around the update code, works great the first time, but then any other updates are ignored.. is there anyway to know wether the page was refreshed vs actual imagebutton postback?

if (!IsPostBack)


Since the update is just setting a flag for that record, on another page that displays those records for a seperate department. IF by chance the first page is still open and the 2nd department resets the flag, if the first page is refreshed, that flag is reset again. so its creating some inconsistant results..

View 7 Replies

Copyrights 2005-15, All rights reserved