dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersPriya jain
naveensanagasetti
Parag Desai
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » .NET »

Binding XML file to DataGrid


Posted Date: 29 Aug 2006      Posted By:: sivavenugopal     Member Level: Silver    Member Rank: 0     Points: 2   Responses: 3



Iam using xml file to bind the datagrid. but when ever iam updating the data it shows unwanted results. Please any one can help me. All the records are appearing more than once.

public void DataGrid1_Edit(Object sender, DataGridCommandEventArgs e)
{
string x1;
ds.ReadXml(Server.MapPath("Customer.xml"));
x1 = (DataGrid1.DataKeys[e.Item.ItemIndex]).ToString();
ds.Tables["Customer"].DefaultView.RowFilter = "CId='" + x1 + "'";
if (ds.Tables["Customer"].DefaultView.Count > 0)
{
error4.Visible = false;
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.ShowFooter = false;
BindDataGrid();
}
else
{
error4.Visible= false;
}
}
public void UpdateXML(Object sender, DataGridCommandEventArgs e)
{
int v1 ;
string x1;
TextBox txt1, txt2;
v1 = e.Item.ItemIndex;
ds.ReadXml(Server.MapPath("Customer.xml"));
x1 = (DataGrid1.DataKeys[e.Item.ItemIndex]).ToString();
ds.Tables["Customer"].DefaultView.RowFilter = "CId='" + x1 + "'";
if (ds.Tables["Customer"].DefaultView.Count > 0)
{
txt1 = (TextBox)e.Item.FindControl("CName_edit") ;
txt2 = (TextBox)e.Item.FindControl("City_edit") ;
DataGrid1.DataSource = ds ;
DataGrid1.DataBind();
ds.WriteXml(Server.MapPath("Customer.xml"));
DataGrid1.EditItemIndex = -1 ;
}
}




Responses

#72354    Author: ab koi apne naam se nahin jaana jayega!!!!!!      Member Level: Gold      Member Rank: 0     Date: 29/Aug/2006   Rating: 2 out of 52 out of 5     Points: 2

u should create a new xml file with same name.
try to this code.
ds.WriteXml(Server.MapPath(".") + "\..\Xml\Customer.xml",+ XmlWriteMode.WriteSchema);

in ur code the new xml file is not created.
plz give me reply whether ur problem is solved or not.



 
#72360    Author: ab koi apne naam se nahin jaana jayega!!!!!!      Member Level: Gold      Member Rank: 0     Date: 29/Aug/2006   Rating: 2 out of 52 out of 5     Points: 2

u should create a new xml file with same name.
try to this code.
ds.WriteXml(Server.MapPath(".") + "\..\Xml\Customer.xml",+ XmlWriteMode.WriteSchema);

in ur code the new xml file is not created.
plz give me reply whether ur problem is solved or not.



 
#72361    Author: ab koi apne naam se nahin jaana jayega!!!!!!      Member Level: Gold      Member Rank: 0     Date: 29/Aug/2006   Rating: 2 out of 52 out of 5     Points: 2

u should create a new xml file with same name.
try to this code.
ds.WriteXml(Server.MapPath(".") + "\..\Xml\Customer.xml",+ XmlWriteMode.WriteSchema);

in ur code the new xml file is not created.
plz give me reply whether ur problem is solved or not.






 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Saving Image
Previous : rss how it will use
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.