473,837 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pass variable in data grid view

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.Dele te("c:\djohn")---->I want to pass the below
asp:HyperLinkFi eld 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.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>eMint Admin</title>
<script language=javasc ript>
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:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>"
SelectCommand=" SELECT [RecordID], [LastName], [FirstName],
[Location], [Phone], [Status], [UserName] FROM [eMints] ORDER BY
[LastName]"
DeleteCommand=" DELETE FROM eMints WHERE (RecordID =
@RecordID)">
<DeleteParamete rs>
<asp:Paramete r Name="RecordID" Type="string" />
</DeleteParameter s>
</asp:SqlDataSour ce>
<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue"
AllowSorting="T rue"
AutoGenerateCol umns="False" DataKeyNames="R ecordID"
DataSourceID="S qlDataSource1" Font-Names="Arial" Width="749px">
<Columns>
<asp:BoundFie ld DataField="Reco rdID"
HeaderText="Rec ordID" InsertVisible=" False"
ReadOnly="True" SortExpression= "RecordID"
Visible="False" />
<asp:BoundFie ld DataField="Last Name"
HeaderText="Las tName" SortExpression= "LastName" />
<asp:BoundFie ld DataField="Firs tName"
HeaderText="Fir stName" SortExpression= "FirstName" />
<asp:BoundFie ld DataField="Loca tion"
HeaderText="Loc ation" SortExpression= "Location" />
<asp:BoundFie ld DataField="Phon e" HeaderText="Pho ne"
SortExpression= "Phone" />
<asp:BoundFie ld DataField="Stat us" HeaderText="Sta tus"
SortExpression= "Status" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:HyperLinkF ield DataTextField=" UserName"
HeaderText="Vie w Website"
Target="_blank" DataNavigateUrl Fields="UserNam e"
DataNavigateUrl FormatString="h ttp://emints.slps.org/emintwebsites/{0}">
<HeaderStyle Font-Underline="True " ForeColor="Blue "
/>
</asp:HyperLinkFi eld>
<asp:TemplateFi eld HeaderText="Rem ove User">
<ItemTemplate >
<asp:Button ID="Button1" runat="server"
CausesValidatio n="false" CommandName="De lete"
OnClientClick=" javascript:retu rn ConfirmDelete() ;"
Text="Delete" />
</ItemTemplate>
<ControlStyle ForeColor="Red" />
<ItemStyle HorizontalAlign ="Center" />
<HeaderStyle Font-Names="Arial" Font-Size="Medium"
Font-Underline="True " ForeColor="Blue " />
</asp:TemplateFie ld>
</Columns>
<RowStyle Font-Size="Smaller" />
<EditRowStyle BackColor="Whit e" ForeColor="Whit e" />
<HeaderStyle Font-Size="Medium" />
<AlternatingRow Style BackColor="#FFF FC0" />
</asp:GridView>

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

Mar 20 '06 #1
0 2400

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

Similar topics

0
4125
by: Mike N. | last post by:
Hello to all: First let me apologize for the length of this question, I've made an attempt to include as much information as is needed to help with the question. I am having problems putting together a query to pull out an alternative hierarchical view of my data. The database is implemented under SQL Sever 2000 and I am writing the front end using VB.Net and ADO.net. The following is the portion of my database structure that I am...
5
2519
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
12
2396
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that field... This grid displayes results based on users search.. public static int numberDiv; private void Page_Load(object sender, System.EventArgs e) {
2
1873
by: Stephan (Germany) | last post by:
Hello, maybe this qustion sounds silly but in VS2005, I'm looking for the same possibilty to entry data for a predefined XML schema in grid view. In VS2003, you were able to do it if you simply set the target schema of your new XML file (which contains nothing besides the xml version line) and switch to data view. This simple way of data entry seems to be gone in VS2005, or is it hidden somewhere else?
0
1176
by: weiwei | last post by:
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...
0
4172
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i "inizialize" the Data Grid View (add a data sorce, filled with notthing at staratup, and hide some columns) when i put a code in the txtCLCOD textbox start a searsh. If i foud something i popolate the Data grid view on the second page. Now the magic if i...
0
8339
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
6
2952
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
1
1848
by: amitjain123 | last post by:
Hello Friends, I have list box and grid view on screen. on selection of list box item, value of selected item gets added into grid view through java script. Now I want to generate the XML string of values from grid view, and pass the xml string to another screen as Session value. How Can we do this? I had tried but I have faced following problem.
0
9852
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10902
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4481
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.