Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > delete button and variable in NavigateUrl in VS2005

Reply
Thread Tools

delete button and variable in NavigateUrl in VS2005

 
 
weiwei
Guest
Posts: n/a
 
      03-16-2006
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("Connection String").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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NavigateURL and javascript David C ASP .Net 1 07-28-2009 02:06 PM
hyperlink and dynamically formed NavigateURL problem Tomek R. ASP .Net 7 02-13-2009 05:12 PM
NavigateURL/DataNavigateURLFormatString and Session Variable tshad ASP .Net 2 08-06-2007 04:41 PM
javascript and navigateurl acadam ASP .Net 0 10-24-2006 10:55 AM
NavigateUrl and Javscript Mike ASP .Net 1 07-17-2004 10:50 AM



Advertisments