Home All Groups Group Topic Archive Search About
Author
30 Dec 2006 11:28 PM
L-E Eriksson
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

Author
31 Dec 2006 12:44 AM
Marcos Mellibovsky
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

Show quoteHide quote
"L-E Eriksson" <L-E@nospam.com> escribió en el mensaje
news:uKFmWpGLHHA.2456@TK2MSFTNGP06.phx.gbl...
> 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
>