Tuesday, 11 October 2016

4. Delete Update command in Data Grid [ VB Dot Net, VB.NET]

Hi All,

It is too easy to incorporate delete and update options with the Data Grid.

Use the Code below [ Design View]. Important parts are highlighted in Blue.


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Main.aspx.vb" Inherits="Default4" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Welcome to Admin Home
    </div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1" DataKeyNames="HUPName">
        <Columns>
            <asp:BoundField DataField="HUPName" HeaderText="HUPName"
                SortExpression="HUPName" />
            <asp:BoundField DataField="HUPPass" HeaderText="HUPPass"
                SortExpression="HUPPass" />
            <asp:CommandField ShowDeleteButton="True" />
            <asp:CommandField ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT [HUPName],[HUPPass] FROM [HUPTable]" DeleteCommand="Delete from HUPTable where HUPName=@HUPName" >
        <DeleteParameters>
                <asp:Parameter Name="HUPName" Type="String" />
                 <asp:Parameter Name="HUPPass" Type="String" />
            </DeleteParameters>
        </asp:SqlDataSource>
    </form>
</body>
</html>

2 comments:

  1. Excellent blog and it’s totally loaded with valid posts on Java and .Net technology. Consider including RSS feed in your blog, so aspirants like me can follow your blog easily. .Net Training in Chennai|Best DOT NET Training institute in Chennai|DOT NET Training Chennai

    ReplyDelete
  2. Exactly, if you learn any one of the programming language, which they have mentioned above is really helpful to get great career in IT web development industry.
    Regards,
    PHP Training in Chennai|PHP Training|PHP Institutes in Chennai

    ReplyDelete