Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Links to functions in the CS file inside a GridView (http://www.velocityreviews.com/forums/t779847-links-to-functions-in-the-cs-file-inside-a-gridview.html)

Andy 04-30-2007 05:32 PM

Links to functions in the CS file inside a GridView
 
Hello,

I'm trying to add a button or a text link(Either will do) to the end of a
row in a GridView. Then for this button to call a function from the CS file
attached to it. I know this can be done with a normal ASP button through
<asp:Button OnClick="FunctionName"></asp:Button>
However, the button and link functions for the GridView control don't seem
to have the OnClick functionality.
Is there any way this can be done?

// ----- Code -----
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="AssignmentDatabase" Width="491px">
<Columns>
<asp:ImageField DataAlternateTextField="imageLocation"
DataImageUrlField="imageLocation">
</asp:ImageField>

<asp:BoundField DataField="itemID" HeaderText="itemID"
SortExpression="itemID" />
<asp:BoundField DataField="itemName" HeaderText="itemName"
SortExpression="itemName" />
<asp:BoundField DataField="price" HeaderText="price"
SortExpression="price" />
<!-- Link here -->
</Columns>
</asp:GridView>

// ----- End Code -----

Thanks,
Andy

Teemu Keiski 05-03-2007 06:04 PM

Re: Links to functions in the CS file inside a GridView
 
Hi,

put the Button in a TemplateField. This way you'll have it as Button and
separate Click.

You can also use ButtonField with a specific command-name , when you "get
the click" by handling GridView's RowCommand event (it's raised when the
Button is clicked)

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net



"Andy" <Andy@discussions.microsoft.com> wrote in message
news:7D979AB1-28C1-43F9-B158-E6928539BAF5@microsoft.com...
> Hello,
>
> I'm trying to add a button or a text link(Either will do) to the end of a
> row in a GridView. Then for this button to call a function from the CS
> file
> attached to it. I know this can be done with a normal ASP button through
> <asp:Button OnClick="FunctionName"></asp:Button>
> However, the button and link functions for the GridView control don't seem
> to have the OnClick functionality.
> Is there any way this can be done?
>
> // ----- Code -----
> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
> DataSourceID="AssignmentDatabase" Width="491px">
> <Columns>
> <asp:ImageField DataAlternateTextField="imageLocation"
> DataImageUrlField="imageLocation">
> </asp:ImageField>
>
> <asp:BoundField DataField="itemID" HeaderText="itemID"
> SortExpression="itemID" />
> <asp:BoundField DataField="itemName" HeaderText="itemName"
> SortExpression="itemName" />
> <asp:BoundField DataField="price" HeaderText="price"
> SortExpression="price" />
> <!-- Link here -->
> </Columns>
> </asp:GridView>
>
> // ----- End Code -----
>
> Thanks,
> Andy




All times are GMT. The time now is 02:48 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.