Dim dtData As DataTable = New DataTable() dtData.Columns.Add(New DataColumn("symbol",Type.GetType(String))) dtData.Columns.Add(New DataColumn("matchPrice",Type.GetType(String))) dtData.Columns.Add(New DataColumn("matchTime",Type.GetType(String))) Dim settings As XmlReaderSettings = New XmlReaderSettings() settings.IgnoreWhitespace = True settings.IgnoreComments = True Dim xmlFile As String = System.IO.Path.Combine(Request.PhysicalApplicationPath,"test.xml") Using reader as XmlReader = XmlReader.Create(xmlFile, settings)) While (reader.Read()) If (reader.NodeType = XmlNodeType.Element And reader.LocalName = "stock" ) Then Dim row As DataRow = dtData.NewRow() row("symbol") = reader.GetAttribute("symbol") reader.ReadToFollowing("matchPrice") row("matchPrice") = reader.ReadElementContentAsString("matchPrice","") reader.Read() row("matchTime") = reader.Value dtData.Rows.Add(row) End If End While End Using GridView1.DataSource = dtData GridView1.DataBind() Thanks, Siva Pinnaka
siva pinnaka
Posts
-
xml Feed -
Format Columns in DataGrid Edit Modeone way is using templateitems. Thanks
-
xml FeedI am giving code below. This used asp.net 2.0 DataTable dtData = new DataTable(); dtData.Columns.Add(new DataColumn("symbol",typeof(string))); dtData.Columns.Add(new DataColumn("matchPrice",typeof(string))); dtData.Columns.Add(new DataColumn("matchTime",typeof(string))); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; settings.IgnoreComments = true; string xmlFile = System.IO.Path.Combine(Request.PhysicalApplicationPath, "test.xml"); using (XmlReader reader = XmlReader.Create(xmlFile, settings)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "stock") { DataRow row = dtData.NewRow(); row["symbol"] = reader.GetAttribute("symbol"); reader.ReadToFollowing("matchPrice"); row["matchPrice"] = reader.ReadElementContentAsString("matchPrice",""); reader.Read(); row["matchTime"] = reader.Value; dtData.Rows.Add(row); } } } GridView1.DataSource = dtData; GridView1.DataBind(); Thanks
-
Unable to get client entered data from webcontroldid you check for !Page.IsPostBack in page_load function when you load default value. otherwise control gets initialized to default value always. Thanks
-
textbox problem in GridviewRowIs it template item? otherwise look Cell values of gridview row in debug mode.you can identify the problem. Thanks
-
VS.NET can't find namespaceDid you add reference to system.web.services dll. Thanks, Siva
-
Going back to previous pagewhen user clicks button to load data you can save datasource in session like below. Session["GridData"] = ds in page_load function of page1 you have to write code like below. if(Session["GridData"] != null && Request.UrlReferrer.ToString() == "Page2") { DataGrid1.DataSource = (DataSet) Session["GridData"]; DataGrid1.DataBind(); } Thanks
-
Session problemby default enablesessionstate is true. Incase it is false,you can enable sessionstate at page level by setting enablesessionstate of page directive to true. Thanks
-
Going back to previous pageQuickest way is to store contents of datagrid in session. if calling page is page2 then populate grid from session. Thanks