Hi greg,
according to the documentation, the XmlDataSource control is tipically used
on read-only scenarios. My suggestion would be to load the xml into a
dataset (assuming you can change the xml accordingly if needed), this will
create a datatable filled in the dataset, then you use this datatable as the
datasource of a gridview for example...
what you think?
Bruno
"Greg Collins [Microsoft MVP]" <gcollins_AT_ms n_DOT_comwrote in message
news:%2******** *******@TK2MSFT NGP06.phx.gbl.. .
Yes, I pull the SQL XML column down and place it in an XmlDocument, and then
I put that into an XmlDataSource, but then I can't read it back out from
there...
protected void Button1_Click(o bject sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@ "Data
Source=.\SQLEXP RESS;Initial Catalog=SqlXmlT est;Integrated Security=True") ;
conn.Open();
string sql = "SELECT [Data] FROM [Record] WHERE ([UserId] = " +
tbUserId.Text + ")";
SqlCommand comm = new SqlCommand(sql, conn);
XmlReader reader = comm.ExecuteXml Reader();
XmlDocument doc = new XmlDocument();
doc.Load(reader );
reader.Close();
conn.Close();
XmlDataSource1. Data = doc.OuterXml;
Repeater1.DataS ourceID = "XmlDataSource1 ";
}
protected void Button2_Click(o bject sender, EventArgs e)
{
string sql = "UPDATE [Record] SET [Data] = '" + XmlDataSource1. Data +"'
WHERE ([UserId] = " + tbUserId.Text + ")";
Response.Write( sql);
}
The Button1 click works fine... but clicking Button2, XmlDataSource1. Data
(which is supposed to be read/write) gives me an empty string.
In the web page, I bound the data to a text box control, so I could try
editing it to see what would happen... but I just get a blank trying to read
the Data property no matter what.
Ideas?
--
Greg Collins [Microsoft MVP]
Visit Braintrove (
http://www.braintrove.com )