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
|
| Author: Satish Kumar J 27 Aug 2007 | Member Level: Diamond | Rating:  Points: 2 |
need to change like following
int i = GridView1.Rows[e.RowIndex]
Regards, Satish.
Regards, Satish My Blog
|