The code for adding the rows is as given below
XmlDocument doc = new XmlDocument();
string url=Server.MapP ath("UserPass.x ml");
doc.Load(url);
XmlNodeList UserList = doc.GetElements ByTagName("user name");
int UserCount = UserList.Count;
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add( new DataColumn("ID" , typeof(string)) );
dt.Columns.Add( new DataColumn("Use rs", typeof(string)) );
dt.Columns.Add( new DataColumn("Sel ect to Edit", typeof(string)) );
dt.Columns.Add( new DataColumn("Sel ect to Delete", typeof(string)) );
for (int i = 0; i < UserCount; i++)
{
dr = dt.NewRow();
XmlNode usernode = UserList.Item(i );
XmlElement userele = (XmlElement)use rnode.ParentNod e;
dr[0] = userele.GetAttr ibute("id");
dr[1] = (usernode.Inner Xml).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
programmaticall y 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!P LEASEtkachenko. com>
Newsgroups: microsoft.publi c.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!P LEASEtkachenko. com> wrote in message
news:eF******** ******@TK2MSFTN GP09.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