very urgent...please

N

Nedu N

From: "Nedu N" <[email protected]>
Subject: not able to read and bind the XML tag data from dataset
Date: Tuesday, August 12, 2003 2:06 PM

All,
I am facing some problem in accessing the data (which is here XML tags
itslelf as data) from dataset....
example:

I have got data as <BTN> in one of the columns in my database table, and i
am able to see this data when write the content of the dataset into a xml
file with
dataset.writexml().
But when i try to bind this dataset to a datagrid i am seeing only spaces in
this specific column...i am okay with other columns...
Any help will be greatly appreciated..

Thanks
Nedu
 
F

Frank Wilson

Nedu,

What is probably happening is that the <BTR> is being
written directly to the browser as <BTR>, which will be
interpreted as a tag. Since the browser doesn't
recognize BTR as a tag, it just ignores it and it appears
blank, though if you view the page source (HTML), you
should see it. To fix this, I would recommend using a
TemplateColumn and encoding the value from the data
binding expression. Here is an example if a 2-column
datagrid, where the first column (col1) will encode the
value, solving your problem:

<asp:DataGrid id=DataGrid1 AutoGenerateColumns=False
runat="server">
<Columns>
<asp:TemplateColumn HeaderText="col1">
<ItemTemplate>
<asp:Label ID=lblCol1 Runat=server><%#
Server.HtmlEncode((String)DataBinder.Eval
(Container.DataItem, "col1"))%></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="col2"
HeaderText="col2" />
</Columns>
</asp:DataGrid>

When you bind a DataSet or DataTable to this control with
HTML or XML content in col1, it will display correctly.
There are other potential issues here as well. If the
data in ANY of the columns is user-input data, then you
should ALWAYS HtmlEncode it to avoid the security risks
associated with cross-site scripting.

hth,
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top