Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2004, 01:59 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default ASP.NET 2 Data Bound CommandArgument

I am using c# and VS.NET 2005 Beta.
Sorry for not using the VS.NET 2005 Forum, but I am unsure if anyone is subscribed to it and this is fairly urgent.

Using a datagrid in the ASP.NET 1.1 I pased a value to the code behind from the item created event using the commandArgument attribute of the conrol I was using.
EG.
Code:
<asp:ImageButton ID="DownloadImageButton" SkinID="IconButton_Download" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Name")%>'  Runat="Server" />
Now in ASP.NET 2 the attrubute does not seem to like taking the databound value.
If I hard code all is fine
EG
Code:
<asp:ImageButton ID="DownloadImageButton" SkinID="IconButton_Download" CommandArgument="c:/MyFile.txt"  Runat="Server" />
I have also tried
Code:
CommandArgument='<%# Eval("FullName")%>'
Which I beleive to be a valid shortcut now.

The IDE does not even seem to recognise the server script tags.
Can anyone tell me if the process of binding data to gridview/datagrid attributes has changes in ASP.NET 2?
Any assistance would be greatly appreciated.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
 
Old October 2nd, 2004, 05:13 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Solution Found.

There was nothing wrong with the command argument at all.
Just needed to access it in the databound event instead of the created event.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old August 10th, 2006, 05:21 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by rodmcleay
 Solution Found.

There was nothing wrong with the command argument at all.
Just needed to access it in the databound event instead of the created event.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Can you explain? i'm at the same problem bu i cant solve.

 
Old August 10th, 2006, 05:38 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Hi,
This is a while back now (2yrs) so I cant be sure what my problem was.
But basically there are several events fired by the datagrid, one being OnItemDataBound and another being OnItemCreated.
There are others.
The command arguement I was looking for could not be found in the databound event, but was available in the ItemCreated event.
This is probably because the actual control that contains the command arguement is not created yet at that stage.
I hope this helps.
Rod

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old August 18th, 2006, 05:35 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

i have this event

protected void linkB(Object sender, CommandEventArgs e)
    {
        switch (e.CommandName)
        {
            // if i select a file
            case "f":
            case "F":

                break;

            //if i select a directory
            case "d":
            case "D":
                Label1.Text = "ruta a " + Server.MapPath(rutaDir + e.CommandArgument);
                RellenaDatagrid(Server.MapPath(rutaDir + e.CommandArgument));
                break;
            default:
                Label1.Text = "Comando no reconocido.";
                break;
        }
        Label1.Text = "You chose: " + e.CommandName + " Item " + e.CommandArgument;
    }

my problem is how to download a file, can you help me?

if you need more info tell me.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Generic Q on data bound program Minos Visual Basic 2005 Basics 1 November 9th, 2006 12:28 PM
retrieving a value from data bound to a repeater beeyule General .NET 0 September 8th, 2005 11:59 AM
Need help with bound data kcrompt2 Classic ASP Professional 0 February 9th, 2005 12:37 AM
Data Bound ComboBox joblot VB How-To 0 May 5th, 2004 12:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.