pass variable in data grid view

W

weiwei

Hi;
I am having trouble to get variable from grid view. here is my
scenario. I want to delete a row in database from web page, in additon,
I also want to delete that user's directory in c:drive. so far, I can
only finished the first part which is to delete the row from database,
Please see below code where I want to get variable in order to delete
the directory. Thanks in advance
<%@ Page Language="VB" Debug="true" %>

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

If Page.IsPostBack Then


'Delete Main Directory
'Directory.Delete("c:\djohn")---->I want to pass the below
asp:HyperLinkField DataTextField="UserName" as a variable to replace
djohn in here!!!


End If
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>
<script language=javascript>
function ConfirmDelete(){
return confirm('Are you sure want to delete this user
account?');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Font-Names="Arial"
Font-Size="Larger" ForeColor="Blue"
Text="eMints Account Admin"></asp:Label><br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [RecordID], [LastName], [FirstName],
[Location], [Phone], [Status], [UserName] FROM [eMints] ORDER BY
[LastName]"
DeleteCommand="DELETE FROM eMints WHERE (RecordID =
@RecordID)">
<DeleteParameters>
<asp:parameter Name="RecordID" Type="string" />
</DeleteParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="RecordID"
DataSourceID="SqlDataSource1" Font-Names="Arial" Width="749px">
<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" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:HyperLinkField DataTextField="UserName"
HeaderText="View Website"
Target="_blank" DataNavigateUrlFields="UserName"
DataNavigateUrlFormatString="http://emints.slps.org/emintwebsites/{0}">
<HeaderStyle Font-Underline="True" ForeColor="Blue"
/>
</asp:HyperLinkField>
<asp:TemplateField HeaderText="Remove User">
<ItemTemplate>
<asp:Button ID="Button1" runat="server"
CausesValidation="false" CommandName="Delete"
OnClientClick="javascript:return ConfirmDelete();"
Text="Delete" />
</ItemTemplate>
<ControlStyle ForeColor="Red" />
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle Font-Names="Arial" Font-Size="Medium"
Font-Underline="True" ForeColor="Blue" />
</asp:TemplateField>
</Columns>
<RowStyle Font-Size="Smaller" />
<EditRowStyle BackColor="White" ForeColor="White" />
<HeaderStyle Font-Size="Medium" />
<AlternatingRowStyle BackColor="#FFFFC0" />
</asp:GridView>

</div>
</form>
</body>
</html>
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top