473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Displaying XML data as is with tags on the datagrid

Hi,

I want to display the XML tags (for the the XML tags is the data that is
stored in a table) on the datagrid using the datasets. But since the data
itself is the XML tag it doesn't appera on the datagrid since it tries to
parse the data before it displays.

Using Server.HtmlEncode, i was able to display the right content on the
datagrid for each and every colum using Template column. But i don't want to
use any template columns since i have got all the columns are having the
data as XML tags as is and i have many cloumns.

So, is there anyway i can directly achieve this while binding the datagrid
with the dataset without using Template columns for each of the coulmns?
Using Server.HtmlEncode, I was able to handle each column like
<%#
Server.HtmlEncode((string)DataBinder.Eval(Containe r.DataItem,"TableColumn"))
%>

Nov 17 '05 #1
2 1956
Please refer to my reply in
microsoft.public.dotnet.framework.aspnet.webcontro ls. Thanks.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
Try performing the encoding in the ItemDataBound Event as follows:

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

switch(e.Item.ItemType)

{

case ListItemType.Item:

// THIS ENCODES ANY TEXT GOING INTO CELLS SO THAT THERE IS NO CHANCE OF
SCRIPT INJECTION

foreach (Control c in e.Item.Controls)

{

TableCell cell = (TableCell) c;

string text = cell.Text;

if (text != " " && text != "")

{

if (text == "&nbsp;") text = "";

cell.Text = HttpUtility.HtmlEncode(text);

}

}

break;

}

}

"Nedu N" <ne****@hotmail.com> wrote in message
news:eB*************@TK2MSFTNGP11.phx.gbl...
Hi,

I want to display the XML tags (for the the XML tags is the data that is
stored in a table) on the datagrid using the datasets. But since the data
itself is the XML tag it doesn't appera on the datagrid since it tries to
parse the data before it displays.

Using Server.HtmlEncode, i was able to display the right content on the
datagrid for each and every colum using Template column. But i don't want to use any template columns since i have got all the columns are having the
data as XML tags as is and i have many cloumns.

So, is there anyway i can directly achieve this while binding the datagrid
with the dataset without using Template columns for each of the coulmns?
Using Server.HtmlEncode, I was able to handle each column like
<%#
Server.HtmlEncode((string)DataBinder.Eval(Containe r.DataItem,"TableColumn")) %>

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Charles Astwood | last post by:
Hi, just starting out working my way round C Sharp and aspx. Used to write all my sites in asp and just need a few pointers in how to display data. I have made a connection to my SQL2000...
0
by: Fronky | last post by:
Hope someone can help. I am still learning, so no laughing please. I am displaying records from a database using Response.Write(""); instead of the usual datagrid method. I am doing it this way...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
1
by: Nedu N | last post by:
i want to display actual XML data (with tags & data) from a table's colum (XML data) in a datagrid's column... by default it shows only yhe content of the XML but not the tags...anyone have an...
3
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of...
0
by: Craig | last post by:
Hello, I have a web form that allows the user to move a unit on a manufacturing router. The user click one of five buttons which each represent a step on the router. When the user clicks any...
0
by: latin & geek via DotNetMonster.com | last post by:
hi! ok, im working on a database application. ive successfully managed to establish a relationship between two tables and display them on a datagrid, edit and add new records to them. now i...
1
by: Tor Inge Rislaa | last post by:
Adding HTML tags to data from SQL server When dragging a table on to a web form in an ASP.NET 2.0 application, the connection is established and the data is displayed in a DataGrid. Is it...
1
by: Death | last post by:
Hi all I am having some trouble on displaying datagrid data from my database as i am a beginner for this The error is when calling the DBCommand . It show incorrect syntax near User. But User...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.