473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

delete button and variable in NavigateUrl in VS2005

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>

Mar 16 '06 #1
0 1160

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: GhislainTanguay | last post by:
How can io delete this element in my AdRotator.xml file with VB.NET I try a lot of things but I don'T have a good result.. Please help me <Advertisements>
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
3
by: Wayne Wengert | last post by:
I have an application where a session variable is set in an ASPX page, The process calls an ASP page and when in that page the session variable appears to be null. How can I pass a session variable...
1
by: GhislainTanguay | last post by:
How can io delete this element in my AdRotator.xml file with VB.NET I try a lot of things but I don'T have a good result.. Please help me <Advertisements>
4
by: Alex | last post by:
Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params....
2
by: sdfarmer | last post by:
I need to Name my menu Controls using a string Array like this: --------------------------------------------------------------- <script language="C#" runat="server"> public String MenuCtrlIds=new...
4
by: interwanderer | last post by:
something very odd... I have installed visual studio 2005 on my machine. I created a console application with visual basic 2005 or C#. I typed something in. tried to delete.. but i couldn't I...
0
by: rn5a | last post by:
All the rows in a DataGrid are accompanied by a CheckBox. When a user checks the rows & clicks a Button, the checked rows get deleted. For e.g. assume that the DataGrid displays 10 rows. A user...
2
by: Blair | last post by:
Hello, I have a old enviromantal path in LIB file that, every time I compile gives a error message. It does not stop the compiler just gives a warning. This has become very annoying. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.