Gridview delete

L

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
 
M

Marcos Mellibovsky

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top