By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,909 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,909 IT Pros & Developers. It's quick & easy.

pass variable in data grid view

P: n/a
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>

Mar 20 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.