Gridview delete

Discussion in 'ASP .Net Web Controls' started by L-E Eriksson, Dec 30, 2006.

  1. L-E Eriksson

    L-E Eriksson Guest

    Hello!

    I have a simple gridview. I am using stored procedures and a my own Data
    Access Layer. Now I want to delete a row.

    Gridview code:

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns=false
    AllowPaging="true" PageSize="5" DataKeyNames="KonsultID">
    <Columns>
    <asp:CommandField ButtonType="Button" ShowDeleteButton="true" />
    <asp:BoundField DataField="ConsultantID" Visible="false" />
    <!--PrimaryKey-->
    <asp:BoundField DataField="FirstName"/>
    <asp:BoundField DataField="LastName"/>
    <asp:TemplateField><ItemTemplate>
    </Columns>
    </asp:GridView>

    and then I have the code behind:
    Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles
    GridView1.RowDeleting
    Dim iVal As Integer = e.RowIndex
    'Code missing here!
    End Sub

    'Now I know which row was clicked, but how do I get the value of the
    ConsultantID?


    Regards

    Clarkie
     
    L-E Eriksson, Dec 30, 2006
    #1
    1. Advertising

  2. you can set the DataKeyNames property of the Grid to ConsultantID, and get
    the value with the DataKeys property of the grid


    --
    Saludos
    Marcos Mellibovsky
    MCT MCTS MCSD.NET MCDBA MCSE...
    Cordoba Argentina

    "L-E Eriksson" <> escribió en el mensaje
    news:...
    > Hello!
    >
    > I have a simple gridview. I am using stored procedures and a my own Data
    > Access Layer. Now I want to delete a row.
    >
    > Gridview code:
    >
    > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns=false
    > AllowPaging="true" PageSize="5" DataKeyNames="KonsultID">
    > <Columns>
    > <asp:CommandField ButtonType="Button" ShowDeleteButton="true" />
    > <asp:BoundField DataField="ConsultantID" Visible="false" />
    > <!--PrimaryKey-->
    > <asp:BoundField DataField="FirstName"/>
    > <asp:BoundField DataField="LastName"/>
    > <asp:TemplateField><ItemTemplate>
    > </Columns>
    > </asp:GridView>
    >
    > and then I have the code behind:
    > Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles
    > GridView1.RowDeleting
    > Dim iVal As Integer = e.RowIndex
    > 'Code missing here!
    > End Sub
    >
    > 'Now I know which row was clicked, but how do I get the value of the
    > ConsultantID?
    >
    >
    > Regards
    >
    > Clarkie
    >
     
    Marcos Mellibovsky, Dec 31, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    18,042
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  2. Sandeep Grover

    delete on delete !

    Sandeep Grover, Jul 12, 2003, in forum: C++
    Replies:
    19
    Views:
    658
    Chris \( Val \)
    Jul 22, 2003
  3. HeroOfSpielburg
    Replies:
    1
    Views:
    413
    Alf P. Steinbach
    Aug 6, 2003
  4. 0to60
    Replies:
    4
    Views:
    325
    Jerry Coffin
    Dec 19, 2003
  5. Mathieu Malaterre

    delete NULL, what about delete[] NULL

    Mathieu Malaterre, Aug 17, 2004, in forum: C++
    Replies:
    2
    Views:
    3,877
    Mathieu Malaterre
    Aug 17, 2004
Loading...

Share This Page