would some kind soul write me two aspx pages?
page1.aspx - has a single hypertext column data grid that lists employees sorted by last name.
hyperlink.text = firstName & " " & middleName & lastName 'middleName has a trailing space.
hyperlink.href = "page2.aspx?empId="&employeeId
page2.aspx - has a single record form with textboxes per field that displays the record chosen on page1.aspx and allows the record to be updated.
I'm new to asp.net but I'm very confident I could handle this if the data source was an SQL database, however, and heres the kicker, here is my data source:
<?xml version="1.0" encoding="iso-8859-1"?>
everything that Iíve been reading seems too convoluted and complex to be realistic. Isn't there some plain and simple way to accomplish this? I'll take any TIDs or howTo docs anyone can throw my way. Ultimately, I want to add records and delete them as well. Thanks in advance.
Last edited by lcscne; 04-08-2005 at 03:40 PM.
This is pretty plain and simple and not too complex. I'd be willing to write them for you for a trade of cash or services! Otherwise, here are some tips on how to approach it.
First, create an object to handle an employee record. Properties for each employee attribute and methods to handle fetching, inserting, and deleting records, etc.
Then, look into the XmlTextReader and XmlTextWriter to handle the reading and writing of your xml file, which you'll use in your fetch, insert, update, and delete methods.
The idea is that you'll use the XmlTextReader to stuff employee objects for each employee and put them into a collection. Then display that collection on Page1.aspx with a datagrid or literal control or whatever.
On Page2.aspx, you'll get the employeeId from the querystring and then use a method in your employee object to stuff an employee object with the record that matches the EmployeeId. Then you'll use that new object to fill your form elements. Once the user clicks submit, you'll update the employee record based on the employeeId. Use a similar approach for insert and deletes too.
Also, you'll need to grant the read/write permission on the XML file to the user that your application is running as. Ie. "ASPNET"
Let me know if you have any questions or some example code. I think I have some code for reading/writing to XML files.
As a test I'm trying to extract the value stored in the Id attribute for a given employeeId here is my function which will set all the employee properties for the class if I can harvest the stinkin id attribute. I know it seems stupid to harvest the id attribute with it being the argument to the function but like I said this is just a test to see if I'm able to harvest anything from the xml file. All I'm getting when I read the classname.emplyeeId is empty string. If I create a line outside the While loop that states "Me.employeeId = 112233" and then read the employeeId property it works fine. Please help
...class properties declared here
Public function fetchEmployee(empId As String) As Integer
Dim recordsAffected As Integer = -1
Dim objReader As New XmlTextReader(employeeXmlFile)
If objReader.NodeType = XmlNodeType.Element Then
If objReader.Value = "employee" Then
If objReader.Value = empId Then
Me.employeeId = objReader.Text
recordsAffected = 1
<?xml version="1.0" encoding="iso-8859-1"?>
<employees xmlns="http://www.mydom.org/employees" xmlns:lcsGlobals="http://www.mydom.org/globals" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mydom.org/employees employees.xsd">
Here's some code that should get you moving a little more. Ask if you need more help.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strAr As System.Collections.Specialized.NameValueCollection = fetchEmployee("i100")
For i As Integer = 0 To strAr.Count - 1
Response.Write(strAr.GetKey(i) & " | " & strAr.Item(i).ToString & "<br />" & vbCrLf)
Public Function fetchEmployee(ByVal empId As String) As System.Collections.Specialized.NameValueCollection
Dim strAr As New System.Collections.Specialized.NameValueCollection
Dim str As System.IO.Stream = System.IO.File.Open(Server.MapPath("employees.xml"), IO.FileMode.Open)
Dim objReader As New XmlTextReader(str)
objReader.WhitespaceHandling = WhitespaceHandling.None
While Not objReader.GetAttribute("Id") = empId
While Not objReader.Name = "employee"
Dim name As String = objReader.Name
Dim value As String = objReader.ReadInnerXml
fetchEmployee = strAr
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)