i want to know the xml

Posted by Subhadip under ASP.NET on 3/18/2011 | Points: 10 | Views : 1039 | Status : [Member] | Replies : 4
I want to know how to display the record from database to grid view using XML in ASP DOT NET??????




Responses

Posted by: SheoNarayan on: 3/18/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Its little difficult to understand your question, however just to display the record from the database you do not need to convert them in SQL, just using ADO.NET to retrieve the database and set DataSource to the GridView that should suffice your need.

Look at the BindData() method in this article - http://www.dotnetfunda.com/articles/article29.aspx.

Thanks


Regards,
Sheo Narayan
http://www.dotnetfunda.com

Subhadip, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsolvers on: 3/18/2011 [Member] Starter | Points: 25

Up
0
Down
You can also convert the XML to serialize object and bind it to grid view.

XML Content
<countries>
<country>
<name>Teacher</name><code>12</code><size>945 amp</size>
</country>
<country>
<name>Sir</name><code>22</code><size>2456 amp</size>
</country>
</countries>
1.Drag a GridView component from the Toolbox.
2.Add to your GridView a PreRender event.
3.Write your code (see below) to bind a DataSet to the GridView.

public partial class _Default : System.Web.UI.Page
{
protected void MyGridView_PreRender(object sender, EventArgs e)
{
// Creates a DataSet and loads it with an Xml Content
DataSet aDataSet = new DataSet();
aDataSet.ReadXml(new StringReader(aXmlDoc.OuterXml));

// Bind the DataSet to the grid view
GridView gv = (GridView)sender;
gv.DataSource = aDataSet;
gv.DataBind();
}
}


Best Regards,

VG
www.TeacherJi.com

Subhadip, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 3/18/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi Subhadip

simple just write that . .

xmlDoc.Save(MapPath("XmlDocument.Test.xml"));


DataSet oDs = new DataSet();

oDs.ReadXml(MapPath("XmlDocumentTest.xml"));

GridView1.DataSourceID = oDs;

GridView1.DataBind();


Best Regard's
Prabhakar

Subhadip, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vforvijay on: 3/18/2011 [Member] Starter | Points: 25

Up
0
Down
hi..try this

http://vbdotnetaddict.blogspot.com/2011/02/how-to-insert-xml-data-into-sql.html

Subhadip, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response