C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

UPDATE THE DATA FROM GRIDVIEW ---TO --XML FILE


Posted Date: 27 Aug 2007      Posted By: Koteswara Rao      Member Level: Gold     Points: 2   Responses: 1



hi frinends
i written the code for updating the students.xml file

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DB_Write_Xml();
BindData();
}
}
public void BindData()
{
ds = new DataSet();
ds.ReadXml(Server.MapPath("STUDENTS.xml"));
GridView1.DataSource = ds;
GridView1.DataBind();
}
public void DB_Write_Xml()
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
sql = "select * from students order by sno";
ad = new SqlDataAdapter(sql, con);
ds = new DataSet();
ad.Fill(ds);
ds.WriteXml(Server.MapPath("STUDENTS.XML"));
Label1.Text = "Students Table Xml File Writing Completed";
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindData();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindData();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindData();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

???????????????????????????????????????Please write the update data to xml file
?????????????????????????Getting the error at first line i.e
'System.Web.UI.WebControls.GridView.Rows' is a 'property' but is used like a 'method'


int i = GridView1.Rows(e.RowIndex)===============ERROR LINE PLEASE
string strId = ((TextBox)GridView1.Rows(e.RowIndex).Cells(2).Controls(0)).Text;
string strName = ((TextBox)GridView1.Rows(e.RowIndex).Cells(3).Controls(0)).Text;
string strTel = ((TextBox)GridView1.Rows(e.RowIndex).Cells(4).Controls(0)).Text;
GridView1.EditIndex = -1;
BindGrid();
// Update the XML file using the new values

DataSet oDs = GridView1.DataSource;
oDs.Tables(0).Rows(i).Item(0) = strId;
oDs.Tables(0).Rows(i).Item(1) = strName;
oDs.Tables(0).Rows(i).Item(2) = strTel;
oDs.WriteXml(Request.PhysicalApplicationPath + "XMLFile.xml");
BindGrid();
}
++++++++++++++++++++++++++++++++++++++++++please change the update coding






Responses

Author: Satish Kumar J    27 Aug 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

need to change like following



int i = GridView1.Rows[e.RowIndex]



Regards,
Satish.

Regards,
Satish
My Blog



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 : XML-GRIDVIEW
Previous : How to dynamically fill listitems to a dropdownlist using javascript
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use