delete button and variable in NavigateUrl in VS2005

Discussion in 'ASP .Net' started by weiwei, Mar 16, 2006.

  1. weiwei

    weiwei Guest

    Hi,
    I have create a data grid view with delete button in VS 2005. so far I
    have able to display the data from database, howvever, there are two
    issues 1)I do not know how to call the delete command. 2), In my data
    grid,<asp:HyperLinkField DataTextField="UserName" HeaderText="View
    Website" NavigateUrl="http://www.msn.org/" & text.UserName & ""
    Target="_blank">, it doesn't work, I want that url
    has the username as variable, anyone can help me out, thanks in
    advance. below is my code,

    <%@ Page Language="VB" Debug="true" %>

    <script language="VB" runat="server" >
    Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)

    If Not Page.IsPostBack Then
    End If

    End Sub

    Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
    GridView1.RowCommand

    Dim RecordID As Button

    Dim myConnection As String =
    ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
    Dim strSQL As String = "DELETE FROM eMints WHERE RecordID = " &
    RecordID & ""
    Response.Write(strSQL)
    Dim Connection As New
    Data.SqlClient.SqlConnection(myConnection)
    Dim myCommand As New Data.SqlClient.SqlCommand(strSQL,
    Connection)
    Connection.Open()
    myCommand.ExecuteNonQuery()
    Connection.Close()

    End Sub


    </script>
    <!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>eMint Admin</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT [RecordID], [LastName], [FirstName],
    [Location], [Phone], [Status], [UserName] FROM [eMints] ORDER BY
    [LastName]">
    </asp:SqlDataSource>

    </div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    AllowSorting="True"
    AutoGenerateColumns="False" DataKeyNames="RecordID"
    DataSourceID="SqlDataSource1" Font-Names="Arial">
    <Columns>
    <asp:BoundField DataField="RecordID"
    HeaderText="RecordID" InsertVisible="False"
    ReadOnly="True" SortExpression="RecordID"
    Visible="False" />
    <asp:BoundField DataField="LastName"
    HeaderText="LastName" SortExpression="LastName" />
    <asp:BoundField DataField="FirstName"
    HeaderText="FirstName" SortExpression="FirstName" />
    <asp:BoundField DataField="Location"
    HeaderText="Location" SortExpression="Location" />
    <asp:BoundField DataField="Phone" HeaderText="Phone"
    SortExpression="Phone" />
    <asp:BoundField DataField="Status" HeaderText="Status"
    SortExpression="Status" />
    <asp:BoundField DataField="UserName"
    HeaderText="UserName" SortExpression="UserName" />
    <asp:HyperLinkField DataTextField="UserName"
    HeaderText="View Website" NavigateUrl="http://www.msn.org/" &
    text.UserName & ""
    Target="_blank">
    <HeaderStyle Font-Underline="True" ForeColor="Blue"
    />
    </asp:HyperLinkField>
    <asp:CommandField ButtonType="Button"
    HeaderText="Remove User" ShowDeleteButton="True">
    <HeaderStyle Font-Names="Arial" Font-Size="Medium"
    Font-Underline="True" ForeColor="Blue" />
    <ItemStyle ForeColor="White" />
    <ControlStyle ForeColor="Red" />
    </asp:CommandField>
    </Columns>
    <RowStyle Font-Size="Smaller" />
    <EditRowStyle BackColor="White" ForeColor="White" />
    <HeaderStyle Font-Size="Medium" />
    <AlternatingRowStyle BackColor="#FFFFC0" />
    </asp:GridView>
    </form>
    </body>
    </html>
    weiwei, Mar 16, 2006
    #1
    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. Mike

    NavigateUrl and Javscript

    Mike, Jul 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    380
    Martin Honnen
    Jul 17, 2004
  2. Tomek R.
    Replies:
    7
    Views:
    8,173
    Sobot
    Feb 13, 2009
  3. acadam

    javascript and navigateurl

    acadam, Oct 24, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    518
    acadam
    Oct 24, 2006
  4. tshad
    Replies:
    2
    Views:
    1,649
    tshad
    Aug 6, 2007
  5. David C

    NavigateURL and javascript

    David C, Jul 28, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    3,982
    David C
    Jul 28, 2009
Loading...

Share This Page