|
Hi,
I have collection of records that means i have collection of value objects of same type. I transfered all the value objects into one custom collection,Now i want to convert this custom collection object into xml to store into the databse.
can anybody guide me how to convert custom collection object into xml object using c#.
Let us assume i have 10 records of employee type. Now i added all these 10 records into employ collection object. Now i want to convert this collection object into xml object.
|
|
|
|
|
Write a method in the employee class that emits XML describing it. Then iterate over your collection, and build your XML that way.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
What type of collection are you using? If the collection itself is serializable, you can mark your employee objects as serializable using the SerializableAttribute (or ISerializable , but that requires more work), and then simply serialize the collection. You can also make use of data contracts and use the data contract serializer. The only drawback to these options (except implementing ISerailzable) is that you don't really have much control over the generated XML.
The other option would be to follow Christian's solution and implement some sort of ToXml() \FromXml() pair of functions that then generate and consume custom generated XML. From there you would want to add a similar set of methods to your collection in order to serialize the list of objects.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
hi,
i am transferring my table to excel from asp.net
the code is as follows.
Dim i As Integer
Dim s As String
s = " "
For i = 0 To 100
s = s & " "
Next
Dim attachment As String
attachment = "sameer.xlsx"
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/vnd.ms-excel"
Response.Write(" nbsp; ")
Response.Write("sameer")
Response.Write("roy")
Response.Write("<table style='z-index: 101; left: 789px; position: absolute; top: 19px' border="2"><tr><td>sameer</td></tr></table>")
Response.End
Now the problem is that when im executing the dispaly in browser the table shows at the required location.However when im streaming the table into excel file it is starting from the extreme left corner .i Tried this one
Response.Write(" " & "<table style="z-index: 101; left: 789px; position: absolute; top: 19px" border="2"><tr><td>sameer</td></tr></table>")
however it didnt work.
Any help is greatly appreciated
<div class="ForumMod">modified on Friday, February 13, 2009 12:51 PM</div>
|
|
|
|
|
In the master page code behind I would like to know what the current page is.
System.Web.HttpContext.Current.Request.Url.AbsolutePath does not return the correct value when called from the master page.
|
|
|
|
|
It actually works for me. What value were you expecting and what did you get?
|
|
|
|
|
try with:
System.Web.HttpContext.Current.Request.FilePath
|
|
|
|
|
Hi All,
How i can used File Upload Control and i limit user to enter any text in this control and only browse in her/him files?
Thank You,
Hoda
modified on Friday, February 13, 2009 12:45 PM
|
|
|
|
|
just use a FileUpload control and block the keypress JS event handler
onkeypress=”javascript: return false;”
FileUpload1.Attributes.Add("onkeypress","javascript: return false;");
Calin
|
|
|
|
|
Hello!
I´ve used asp:panel for rendering divs I need to manage from code-behind. I recently heard asp:panel can render into table on some browsers. Is this true, and which browsers would that be?
modified on Friday, February 13, 2009 8:56 AM
|
|
|
|
|
livez wrote: I recently heard asp:panel can render into table on some browsers. Is this true,
All Server side control rendered to HTML Control.
|
|
|
|
|
yes of course, but I was under the impression asp:panel rendered into div.
|
|
|
|
|
|
Thanks for your reply!
Guess I´m just gonna use divs with runat=server instead.
|
|
|
|
|
How can we open the Popup window while clicking SWF Object. Is it Possible. I want to open a popup window while clicking an embeded object.
|
|
|
|
|
|
Hello
i want searching code in database
mu application in id, name ,city three fields in one table from database
but user input name or id or city (any one)at that time give result
plz give me code thanx.,.,
|
|
|
|
|
hi JAS
I dont know where to start , because i dont know how much you know about what you just asked, but from the Info you gave i assume you want to search your table based on ID or City and return a something like Zipp code, well in my Country we call that postal code. So that can be done the First thing you have to create a Stored Procedure that that will do that for you like this
CREATE PROC PRCGETCODE
(
@CITY INT,
@CITY_CODE INT OUTPUT
)
SET @CITY_CODE(SELECT TOP 1 CODE FROM WHERE CITY = @CITY)
............
............. RETURN A CODE OR ZERO, TO GET RID OF NULLS
...............
and in your C# code do something like this
con = new SqlConnection(constring);
cmdselect = new SqlCommand();
cmdselect.CommandText = "DBO.PRCGETCODE";
cmdselect.CommandTimeout = 0;
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.Connection = con;
int City_Code= 0;
try
{
con.Open();
City_Code = cmdselect.ExecuteNonQuery();
}
catch (SqlException)
{
throw;
}
finally
{
con.Close();
}
return City_Code;
}
and later you bind your result to a control, hopefull not Gridview , because this is one value lol!!!!!!!!
Hope i helped
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Hello Everybody
I am using FormsAuthentication on web.confiq file.
I want to send back to previus page if login successful from login.aspx
Thanks
Sarfaraj
Sarfarj Ahmed
|
|
|
|
|
Hi,
I have created a VS2005 webservice with WSE3.0 (UsernameToken, Policies & SoapHeader). While access & run the service in local, its working fine. I have successfully deployed into the server. But when I try to access one of the WebMethods from the service in my local application, I am getting the following error :
WSE910: An error happened during the processing of a response message, and you can find the error in the inner exception. You can also find the response message in the Response property.
How to resolve this? Thanks in advance
|
|
|
|
|
Hai Friends,
I am using membership table for new user creation.I want to get the password of a logined user.How is it possible.I set password format in webconfig to Hashed.So an error of not decode hashed password is occur.How can i get the users password so that i want to check the user entered correct password.Please help me.I need it urgently.
|
|
|
|
|
SreejithAchutan wrote: I need it urgently.
Of course it's urgent, however, it is very bad form to declare it in you post. This a volunteer site, people volunteer their time to answer questions, it isn't their primary job. Have a little respect for that.
To answer your question, you can't get the password, it's hashed for that purpose. What you can do is compare the hash values for the passwords to check them.
only two letters away from being an asset
|
|
|
|
|
I've a crystal report of VS 2005. I'm showing date field in that report. I've set the dd/mm/yyyy format for that field. If I run the aplication, it is showing the expected format (dd/MM/yyyy). But If I run after deploying the setup, It is showing mm/dd/yyyy format. I want dd/MM/yyyy formate.
I set my format in regional settings also.
Pls help me. Thanks in adv.
Balasubramanian K.
|
|
|
|
|
Hi,In my project i want to display todays birthday names in page load event.
I created a field called birthday in sql. It stored as date and time. Now i want to compare only the datepart of birthday with datepart of getdate()?
I write the query like this. But it got some errors.
select (datepart(dd,getdate()),datepart(mm,getdate()),datepart(yy,getdate()))=(datepart(dd,cre_date()),datepart(mm,cre_date()),datepart(yy,cre_date())) from photos
Can anyone correct this?
|
|
|
|
|
Declare @TodaysDate As DateTime
Set @TodaysDate = convert(varchar,GetDate(),101) --only datepart
Select * from photos
where convert(varchar,YourDateColumn,101) = @TodaysDate
|
|
|
|