Hi J,
Haven't heard from you. How are you doing on this issue, have you got any
further ideas or does the suggetions in my last reply helps a little? If
there're anything else we can help, please feel free to post here. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 40441496
| References: <ex**************@TK2MSFTNGP10.phx.gbl>
<er**************@TK2MSFTNGP15.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From:
st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Wed, 02 Nov 2005 01:59:42 GMT
| Subject: Re: Gridview command event args!
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <MN**************@TK2MSFTNGXA01.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 87
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:135393
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi J,
|
| welcome.
| Regarding on the setting additional parameter for the button in GridView
| Row, I think the best choice is using a template field ( we can do it
from
| converting a button field into template field in gridview). In template
| field, we can specify additional databinding field in the template like:
|
| =================
| <asp:TemplateField ShowHeader="False">
| <ItemTemplate>
| <asp:LinkButton ID="LinkButton1" runat="server"
| CausesValidation="false" CommandName=""
| CommandArgument='<%# Eval("CategoryName") %>'
| Text="Button"></asp:LinkButton>
| </ItemTemplate>
| </asp:TemplateField>
| </Columns>
| </asp:GridView>
| ===================
|
| In addition, we can also use the ItemDataBound event and manually store
the
| value into any other hidden control's attribute (or just in the
| GridViewRow.Attributes ) and retrieve back later, e.g:
|
| =================
| protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs
| e)
| {
| if (e.Row.RowType == DataControlRowType.DataRow)
| {
| DataRowView drv = e.Row.DataItem as DataRowView;
| e.Row.Attributes.Add("myattr", drv[1].ToString());
| }
| }
| ==================
|
| we can then retrieve it back through the following code in RowCommand:
|
| =========
| protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs
| e)
| {
| GridViewRow row = ((Control)e.CommandSource).NamingContainer as
| GridViewRow;
|
| Response.Write("<br>myattr: " + row.Attributes["myattr"]);
| }
| ===========
|
| Anyway, there're several means to achieve this, we can use the one we
like.
| Hope helps.
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure!
www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
| --------------------
| | Reply-To: <wa********@newsgroups.nospam>
| | From: <wa********@newsgroups.nospam>
| | References: <ex**************@TK2MSFTNGP10.phx.gbl>
| | Subject: Re: Gridview command event args!
| | Date: Tue, 1 Nov 2005 10:24:39 -0800
| | Lines: 22
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | X-RFC2646: Format=Flowed; Response
| | Message-ID: <er**************@TK2MSFTNGP15.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet:135302
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Can anyone help me with this?
| |
| |
| | <wa********@newsgroups.nospam> wrote in message
| | news:ex**************@TK2MSFTNGP10.phx.gbl...
| | > Hello,
| | >
| | > I am trying to get add a product to a cart from a gridview control
when
| a
| | > button in the gridview is clicked. I have a book on how to do this
in
| | > asp.net 2.0 but it is done by specifying the "DataTextField" as the
| | > productID of the product that I want to add. This works but the
button
| | > displays the productID as the text instead of "Add to Cart".
| | >
| | > What is the best way to get this to work?
| | >
| | > Thanks in advance.
| | >
| | > J
| | >
| | >
| |
| |
| |
|
|