|
When you write from the XmlSerializer, you can use an XmlWriter (as a TextWriter). Use the static Create method off of XmlWriter to make a writer that has XmlWriterSettings. Using the settings, you can tell it to not put the declarations.
|
|
|
|
|
Thanks Dustin, that's just the ticket.
One last thing - is it possible to remove the xmlns:xsi and xmlns:xsd attributes using settings?
I've had a play around, but they are staying put.
Cheers
Tris
|
|
|
|
|
That one's a bit tougher. Are you using namespaces in the attributes on the type?
|
|
|
|
|
I finally got to a dev environment where I could test it. There really isn't a way to wipe those attributes off of there, which I think is a very frustrating part of using XmlSerializer. Some of the tactics I've taken in the past are to implement IXmlSerializable (which isn't fun because you have to read and write from the xml stream yourself) or to load the serialized xml into an XmlDocument and remove the namespaces manually. I'm not sure if MVPXML[^] has done anything to handle this but you may want to check it out.
|
|
|
|
|
Hi All,
Please help..
How to delete a row from Datagrid in CodeBehind ??
Thanks in advance..
|
|
|
|
|
You don't delete it from the datagrid. Delete it from your datasource.
only two letters away from being an asset
|
|
|
|
|
hi,
first of all create a template column , add an imagebutton on that and set Command Name property of that imagename as Delete. Defind DataKey of the datagrid as whatever ID or Field you want to use to delete the record from DB. Now write the follwing code:
private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
try
{
int ID = Convert.ToInt32(DataGridInventory.DataKeys[e.Item.ItemIndex]);
//Pass this ID to the stored procedure where you have to write delete query.
or
SqlConnection con=new SqlConnection("<connectioname>");
con.Open();
SqlCommand cmd=new SqlCommand();
cmd.CommandText="delete form Table1 where id="
+ID";
cmd.Connection=con;
cmd.ExecuteNonQuery();
con.Close();
}
catch(Exception ex)
{
con.Close();
string strMsg=ex.Message;
}
}
|
|
|
|
|
|
the code segment that u sent me
using (StreamWriter sw = new StreamWriter filename)) { <br />
try<br />
{<br />
foreach (DataRow row in myDataTable)<br />
{ <br />
sw.WriteLine(row["columnName1"]);<br />
sw.WriteLine(row["columnName2"]);
sw.WriteLine("<body>");<br />
sw.WriteLine("" + row["columnName1"]);<br />
sw.WriteLine("</body>")
}<br />
}<br />
catch (Exception er)<br />
{
}<br />
finally<br />
{ sw.Close(); }<br />
}
gives me a syntax error
foreach statement cannot operate on variables of type 'System.Data.DataTable' because 'System.Data.DataTable' does not contain a definition for 'GetEnumerator', or it is inaccessible<br />
what am i doing wrong??
|
|
|
|
|
Replace
foreach (DataRow row in myDataTable)
by
foreach (DataRow row in myDataTable.Rows)
Regards
Shajeel
|
|
|
|
|
u're the brainiest
Regards
Saira
|
|
|
|
|
You need to iterate over myDataTable.Rows.
foreach (DataRow row in myDataTable.Rows)
Sometimes it's the little things that catch us out.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yep, my fault. Sorry. Hope you got it working!
|
|
|
|
|
Hello every one,
well I've encountered a really weird eror in datagridview here. I'm workin in C# 2.0 windows form application and there is a dgv(datagridview) on it that is attached to a view..I added an unbound column in it to take the quantity from the user. Now when I get the value of quantity from a cell of that column I get a null when I put 1 in that cell where is its always the correct value whenever its not 1. Can any buddy plz tell me whats happening here. I receive the correct value when its 0, 2, 3 4 ... but its a null when its 1... What should I do.. is it a bug in VS or what??
thanks in advance
Rocky
|
|
|
|
|
can u post ur code to give an idea what u r doin
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
well I sorted out that wrror by making a new column with a different name and I deleted that column but it was weird u know...
|
|
|
|
|
How are you attaching it to the view, through a bindingsource or just saying DGV.DataSource=theView; Also, how are you trying to access the value of the cell?
|
|
|
|
|
I attached it through a binding source but now the problem is solved as I just deleted that column and made a new one with a different name. I bound the datagrid with the usual procedure of using a datasource u know but I still dont know what happened there but its working fine now. thank God..
thanks alot!
Rocky
|
|
|
|
|
Does anybody have an idea about autoscalling?
the problem i have is with changing the screen resolution. When screen resolution changes the controls get messed up. I tried using the anchor and dock properties for the user controls and the panels. some worked and some not. Don't ask me why cause i don't know. i made the same changes for all but some worked and some didn't. i made some search to find an alternative way for using the dock and anchor properties and i found that i can use the autoscalling.
i don't know how to use and i can't find any sample code or sample project that teach me how to use it. so if anybody have an idea about it, that would be very helpfull.
thanks in advance.
|
|
|
|
|
how can i log into a site using my application?.
i mean, how do i send the data (as in www.site.com/login.asp?user=bla&pass=bla);
i tried several options and failed, please help me
|
|
|
|
|
I'm sorry, but this question is a bit vague. Do you mean, how do you start a web page from a desktop application? If you do, then use the following:
Process.Start("www.site.com/login.asp?user=bla&pass=bla");
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
no, i want to retrieve details from a website but you have to be logged in to be able to see them, so i want to log in and then get the details..
|
|
|
|
|
See this[^] article.
/ravi
|
|
|
|
|
actually it's nothing even close to what i wanted <_<
i just want to login to a site using my prog...as in www.site.com/login.asp?user=sharpie&pass=sharpie
...
|
|
|
|
|
sharpiesharpie wrote: actually it's nothing even close to what i wanted
Your previous message (i want to retrieve details from a website but you have to be logged in to be able to see them, so i want to log in and then get the details..) seems to imply that you want to (a) programatically login to your website and (b) retrieve the information that's presented to the user (upon a successful login). If that is indeed what you meant, you could use the WebResourceProvider class to do that.
If not, you may want to consider rephrasing your question or providing more detail.
/ravi
|
|
|
|