pradeep kumar

pradeep kumar

  • NA
  • 94
  • 67k

Datatable to XML

Oct 12 2012 5:17 AM
I have a grid that contains name,value and value is text box.
submit button is outside the grid.
on the click of submit button the grid values should save as xml data in database..,
need urgent solution...,

private DataTable CreateDatatable()
    {

        DataTable dt = new DataTable();
        dt.Columns.Add("Boundary_Id");
        dt.Columns.Add("Boundary_Name1");
        dt.Columns.Add("Boundary_Name2");
        dt.Columns.Add("Boundary_Value");
        dt.Columns.Add("Status");


       
            DataRow dr = dt.NewRow();
            dr["Boundary_Id"].ToString();
            dr["Boundary_Name1"].ToString();
            dr["Boundary_Name2"].ToString();
            dr["Boundary_Value"].ToString();
            dr["Status"].ToString();
            dt.Rows.Add(dr);
           
      


        return dt;
    }

protected void btnSubmit_Click(object sender, EventArgs e)
    {
 try
        {

            BoundaryMapping objBoundmap = new BoundaryMapping();

            objBoundmap.Boundary_Name1 = ddlbcon.SelectedValue;

            foreach (GridDataItem item in gvboundarymap.MasterTableView.Items)
            {

                if (item is GridDataItem)
                {

                    TextBox txtbvalue = (TextBox)item.FindControl("txtbvalue");
                    objBoundmap.Boundary_Value = txtbvalue.Text;


                }


            }
            DataSet ds = new DataSet();
           
            using (StringWriter sw = new StringWriter())
            {
               
                dt.WriteXml(sw);
                XML = sw.ToString();


            }
            string strStatus = string.Empty;
           



        }

this wat i done how to proceed..?


}

Answers (1)