Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 February 9th, 2006, 10:27 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default Using a GridView commandfield

Hi All

I have both the Beginning & Professional ASP.Net2 books with me and have no problem using the Gridview and SQLDatasource using VWD's help. But what I am looking to do now is create a commandfield button within the GridView that triggers an event which ultimately performs a stored procedure through the SQLDataSource.

The reason being is that I have 2 Gridviews which have seperate SQLDataSources as they point to different tables and I am wanting to DELETE a Selected row from Table1's Gridview and INSERT into Table2's Gridview.

The way I thought I could do this is that each Gridview when selecting a row's command button would trigger an event which manually performs their SQLDatasource's Stored Procedure. But I am really not sure on the Syntax at all.

If you could point me in the direction of a good site or your knowledge, that would be great.

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old February 9th, 2006, 02:47 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Create a button column. Set the command name property (Ex "MyCommand"). Then use the RowCommand event of the grid:

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles GridView1.RowCommand
        If e.CommandName = "MyCommand" Then
         ...Do your stuff here

        End If
    End Sub

Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
Gridview 2.0 holaman ASP.NET 2.0 Basics 2 November 7th, 2007 03:02 AM
gridview azymd777 ASP.NET 2.0 Basics 2 July 4th, 2007 01:10 PM
GridView simonwilbert ASP.NET 2.0 Basics 4 August 12th, 2006 02:40 AM
GridView DARSIN .NET Framework 2.0 2 December 1st, 2004 06:12 AM





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