The code for adding the rows is as given below
XmlDocument doc = new XmlDocument();
string url=Server.MapPath("UserPass.xml");
doc.Load(url);
XmlNodeList UserList = doc.GetElementsByTagName("username");
int UserCount = UserList.Count;
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("Users", typeof(string)));
dt.Columns.Add(new DataColumn("Select to Edit", typeof(string)));
dt.Columns.Add(new DataColumn("Select to Delete", typeof(string)));
for (int i = 0; i < UserCount; i++)
{
dr = dt.NewRow();
XmlNode usernode = UserList.Item(i);
XmlElement userele = (XmlElement)usernode.ParentNode;
dr[0] = userele.GetAttribute("id");
dr[1] = (usernode.InnerXml).ToString();
dr[2] = "EDIT";
dr[3] = "DELETE";
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
UserDetailsGrid.DataSource = dv;
UserDetailsGrid.DataBind();
Now it does not display the id value in the data grid. I want to refer to
this value depending on which particular users Edit or Delete link has been
clicked..so I need the value for id. If i add this attribute
programmatically and increment it after adding each user ...i face a problem
when deleting the users ...because if the 10th user has been deleted i wud
need to update the id of all the remaining users ...which does not make
sense...so this has to be done automaticaaly..
Any Advice wud be helpful...
Thanx,
Smita.
----- Original Message -----
From: "Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com>
Newsgroups: microsoft.public.dotnet.xml
Sent: Sunday, January 25, 2004 1:51 PM
Subject: Re: Xml Attribute..id problem??
smita wrote:
What I want is this id attribute to increment automatically. For starters, ID in XML cannot be a number. It must be a name.
So I declared it of type "ID" ..but how do i access the value of this
attribute.
When i add a record it gets added to the xml file but the id attribute
does not show..So how do i refer to this attribute.
Well, you forgot to explain which API you are using for getting values
and adding rows.
--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com
"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl... smita wrote:
What I want is this id attribute to increment automatically.
For starters, ID in XML cannot be a number. It must be a name.
So I declared it of type "ID" ..but how do i access the value of this
attribute.
When i add a record it gets added to the xml file but the id attribute
does not show..So how do i refer to this attribute.
Well, you forgot to explain which API you are using for getting values
and adding rows.
--
Oleg Tkachenko
XmlInsider
http://blog.tkachenko.com