Showing posts with label format. Show all posts
Showing posts with label format. Show all posts

Saturday, March 31, 2012

String to date

I have a string which contains a date in "MM/dd/yyyy" format. How to I convert that in VB to "dd/MM/yyyy"

Please see this post.

http://forums.asp.net/1167602/ShowPost.aspx


Thanks for that

String to html conversion

I want to send an email in html format through code. Problem I am having is converting the string into html without and grumps. Does .net have a class that converts this easily. I have tried doing a search and replace chracters, but still having issues. Or has anyone done anything similar?

BC

hi bcanonica,

do you have some sample code on you that i could look into?

regards,

zee


Hello,

By default, email sent with System.Net.Mail is formatted as plain text. To format as Html, set the MailMessage.IsBodyHtml property to true.

[ C# ]

 //create the mail message MailMessage mail = new MailMessage(); //set the addresses mail.From = new MailAddress("me@.mycompany.com"); mail.To.Add("you@.yourcompany.com"); //set the content mail.Subject = "This is an email"; mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>"; mail.IsBodyHtml = true; //send the message SmtpClient smtp = new SmtpClient("127.0.0.1"); smtp.Send(mail);


[ VB.NET ]

 'create the mail messageDim mail As New MailMessage()'set the addressesmail.From = New MailAddress("me@.mycompany.com")mail.To.Add("you@.yourcompany.com")'set the contentmail.Subject = "This is an email" mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>"mail.IsBodyHtml = True'send the messageDim smtp As New SmtpClient("127.0.0.1")smtp.Send(mail)

Not exactly what I was looking for. I want to know how I can convert an html email that I create in Publisher to to a string so I can send it in the body of mailMessage object. Is their a namespace that converts from a string to html and vis versa. Meaning using quotes and other characters that do not match.

BC


You can useServer.HtmlEncode and alsoHttpServerUtility.HtmlEncode Method andHttpServerUtility.HtmlDecode Method.

Here still is another way to do such things:Rendering a control as an Html String

HTH

Wednesday, March 28, 2012

String was not recognized as a valid DateTime

I retrive data from web service. My date is in the format 20/6/2006 0:00. When I try to format date with the following code it gives me above error.

the code is

String.Format("{0:MMMM d, yyyy}",Date.Parse(_landcorReport.vrValuationDate))

please help me

please guys can any one help me?
Hi,
Make sure you are getting valid date in _landcorReport.vrValuationDate. Try using TryParse with an out variable of DateTime type, and then try to format it.

DateTime dt;
bool result = DateTime.TryParse(_landcorReport.vrValuationDate.ToString(), out dt);

Thanks,


unless you are doing Visual J#, you should be usingDateTime.Parse instead

String.Format ( "{0:MMMM d, yyyy}",DateTime.Parse ( _landcorReport.vrValuationDate ) )

that should work assuming of course that _landcorReport.vrValuationDate returns a string that is convertible to a valid date


ReyN:

unless you are doing Visual J#, you should be usingDateTime.Parse instead

String.Format ( "{0:MMMM d, yyyy}",DateTime.Parse ( _landcorReport.vrValuationDate ) )

that should work assuming of course that _landcorReport.vrValuationDate returns a string that is convertible to a valid date

If the input string cannot be converted to DateTime, an exception will be thrown. If you are not sure whether the input string can be converted to datetime, use the TryParse, as this method tries to parse only if the input string is valid and gives you the result if succeeded into the out variable. If you are not using TryParse, you need to use a try {} catch {} block to handle the exception.

Thanks

This method is available in .Net 2.0 while I'm working in .Net 1.1
Hi
Check if the value of_landcorReport.vrValuationDate is a valid date, or use your statement in try catch block

THanks

String was not recognized as a valid DateTime Error

I am extracting a DateTime string from a SQL table, and I want to format it. However, when I try to convert the string to a datetime, I get the error:
"String was not recognized as a valid DateTime"
Here is my code:
private string dateFormatting(String theDate)
{
DateTime strDate;
strDate = Convert.ToDateTime(theDate);
strDate = strDate.ToString("M");
return strDate;
}
theDate has the value of "5/11/2005 5:10:25 PM". If I copy-and-paste the string into the code (instead of "theDate"), it compiles properly. However, leaving it in a variable always return the error above.
What might cause this problem?

Thanks

I'm having the same trouble... Can it be a bug?
Regards,
Luis Sim?es


Your variable "strDate" is a DateTime type. You are trying to fill a DateTime variable with a string:

strDate = strDate.ToString("M");
try this:

privatestring dateFormatting(string theDate)

{

DateTime strDate;

strDate = DateTime.Parse(theDate);

string stringDate = strDate.ToString("M");

return stringDate;

}



this may sound like a dumb question, but are you absoulutly sure that the date you paste in is the same date that your code is reciveing, as in have you place a breakpoint in and checked this for sure. One possibility is that the source of your date string has a different culture to the server running the convert.

On a side note, if your function only formats a date then why not only have yout functon accept a date rather then a string? In other words what context is this function performing its role of the conversion, is it from a databind or from a database object?


I'm not sure if it's gonna change anything but.. try to convert like this..
Convert.ToShortDateTime(variable);
anyway... I guess it changes nothing... except that the date will be returned different..
I am not sure if it's gonna change anything.. but.. try to use like this:

Convert.ToShortDateTime(var_name);
I don't know if it will make any difference at all.. I think it wont accutally... I mean.. about this error...

andrew_K wrote:

this may sound like a dumb question, but are you absoulutly sure that the date you paste in is the same date that your code is reciveing, as in have you place a breakpoint in and checked this for sure. One possibility is that the source of your date string has a different culture to the server running the convert.

On a side note, if your function only formats a date then why not only have yout functon accept a date rather then a string? In other words what context is this function performing its role of the conversion, is it from a databind or from a database object?

I am positive that the date I pasted is the same as the date that my code is receiving.

I have the function accept a string because it is called from a databind. I have tried converting the date before passing it to the function, and it returns the same error. I'd post the code, but I am at home now *-)


DevSlick wrote:

Your variable "strDate" is a DateTime type. You are trying to fill a DateTime variable with a string:

strDate = strDate.ToString("M");
try this:

privatestring dateFormatting(string theDate)

{

DateTime strDate;

strDate = DateTime.Parse(theDate);

string stringDate = strDate.ToString("M");

return stringDate;

}



It still returned the same error onstrDate = DateTime.Parse(theDate);
This is very weird.
Weird, it worked for me
This is driving me crazy. Here's the entire code. Maybe the problem is somewhere else. The stored procedure returns two values, the date and an id. Any help would be greatly appreciated!

protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource dsAdmin = new SqlDataSource();
dsAdmin.ConnectionString = "Data Source=(local);Initial Catalog=birdhair;Integrated Security=True";
dsAdmin.SelectCommand = "usp_Admin_ArchiveList";
dsAdmin.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
Parameter sParam1 = new Parameter();
sParam1.Name = "month";
sParam1.Type = TypeCode.Int32;
sParam1.DefaultValue = DateTime.Now.Month.ToString();
dsAdmin.SelectParameters.Add(sParam1);
Parameter sParam2 = new Parameter();
sParam2.Name = "Year";
sParam2.Type = TypeCode.Int32;
sParam2.DefaultValue = DateTime.Now.Year.ToString();
dsAdmin.SelectParameters.Add(sParam2);
DataGrid gridYear = new DataGrid();
gridYear.AutoGenerateColumns = false;
gridYear.DataSource = dsAdmin;
placeholder.Controls.Add(gridYear);
HyperLinkColumn column = new HyperLinkColumn();
column.DataNavigateUrlField = "LogID";
column.DataNavigateUrlFormatString = "edit.aspx?LogID={0}";
column.DataTextField = "LogTimeStamp";
column.DataTextFormatString = dateFormatting("{0}");
gridYear.Columns.Add(column);
gridYear.DataBind();
}
private string dateFormatting(String theDate)
{
DateTime strDate;
String stringDate;
strDate = DateTime.Parse(theDate);
stringDate = strDate.ToString("M");
return stringDate;
}

string.format gridview cell

I am trying to use the following code to format specific cells in my gridview and failing. I can successfully format a column by setting htmlencode off and string.format for the field, but I need to control the formatting at the cellular level :-). I can get font, color etc, but not string.format. I can add to the string i.e. in the code below everything works, except the <code> "

Case"Sales"

For i = 1To e.Row.Cells.Count - 1

IfNot RTrim(e.Row.Cells(i).Text.ToString) =""Then

e.Row.Cells(i).Text =String.Format("{0:c}", e.Row.Cells(i).Text)

EndIf

Next

"</code>

Also if not rtrim(e.row.cells(i).text.tostring = "" does not do anything for me, what is the correct syntax so that empty cells do not recieving this formatting?

<code>

Sub gridview2_rowdatabound(ByVal senderAsObject,ByVal eAs GridViewRowEventArgs)Handles GridView2.RowDataBound

Dim iAsInteger

If e.Row.RowType = DataControlRowType.DataRowThen

e.Row.Cells(4).Font.Bold =True

e.Row.Cells(8).Font.Bold =True

e.Row.Cells(12).Font.Bold =True

e.Row.Cells(16).Font.Bold =True

e.Row.Cells(17).Font.Bold =True

e.Row.Cells(4).BackColor = Drawing.Color.LightGray

e.Row.Cells(8).BackColor = Drawing.Color.LightGray

e.Row.Cells(12).BackColor = Drawing.Color.LightGray

e.Row.Cells(16).BackColor = Drawing.Color.LightGray

e.Row.Cells(17).BackColor = Drawing.Color.LightGray

SelectCase RTrim(e.Row.Cells(0).Text)

Case"Sales"

For i = 1To e.Row.Cells.Count - 1

IfNot RTrim(e.Row.Cells(i).Text.ToString) =""Then

e.Row.Cells(i).Text =String.Format("{0:c}", e.Row.Cells(i).Text)

EndIf

Next

Case"Gross Profit"

For i = 1To e.Row.Cells.Count - 1

IfNot e.Row.Cells(i).TextIsNothingThen

e.Row.Cells(i).Text ="$" & e.Row.Cells(i).Text

EndIf

Next

EndSelect

EndIf

EndSub

</code>

Thanks

if you change your trouble code to this:

String str =String.Format("{0:c}", e.Row.Cells(i).Text);
e.Row.Cells(i).Text =String.Format("{0:c}", e.Row.Cells(i).Text)

and debugg it,

what result to you get for str?
Does it format it?
Does your code even go into the if statement above the trouble line?

foregive my ignorance, is there a way to see the value of a variable in vs.net during a debugging session besides assigning it to a label in my web app?

I do know that the code does go into the if statement as changing the code to me e.row.cells(i).text = "$" & e.row.cells(i).text gives me the expected result in the gridview cell.

Also the app compiles without error.

Thanks in advance for your assistance.


Ok, I placed a break immediately after the str1 = string.format...

and in my vs.net 2005 it shows the number with no formatting.

"Good news is I now see how to trouble shoot my code without adding extra labels etc on my application to display variables just so that I know what is being assigned to the variable" Bad news, I still don't see why string.format is not working.


Oops. Disregard this post, plz.


Try this:

IfNot RTrim(e.Row.Cells(i).Text.ToString) =""Then

e.Row.Cells(i).Text =String.Format("{0:c}", Double.Parse(e.Row.Cells(i).Text))

EndIf


that works perfectly. Thank you

String.Format comma for thousands and two decimal points only

I am trying to come up with theString.Format expression to format a number that will have a comma to separate the thousands and a period for the decimals ( I want to show only two decimals )

Will this work for you?

String.Format("{0:N2}", MyNumber)

string.format Problem

I am trying to fill in a summary in the footer of my grid view but I keep getting an error

Message="Format specifier was invalid."
make sure your method argumements are in the right format

lblsummary.Text = String.Format("Total hrs: {0:d}", hrtotalsTotal)

e.Row.Cells(2).Text = (hrtotalsTotal / 60).ToString(

"d")

I got this format from msdn what is causing this

Hi,

What is your hrtotalsTotal value?

From what I can see, you're trying to convert a double to DateTime presentation format... It does not make any sense. You should use TimeSpan object. And I think your hrtotalsTotal is actually a total number of minutes... anyways, try this:

Dim totalHoursAs Double = 3.4'3 hours 24 minutesDim tsAs TimeSpan = TimeSpan.FromHours(totalHours)Response.Write(ts.ToString())

hrtotalstotal is declared as a decimal and is the sum of a grid view col.

dim hrtotalstotal as decimal

I am just deviding hrstotalstotal/60 to get total hrs. in a decimal format ie 75 min = 1.15 hrs....

nothing to do with any dates or times.

e.Row.Cells(2).Text = (hrtotalsTotal / 60).ToString("d")


ok then.

My example should help you out on this.


Your format specifier is invalid becoz you have declared the variable as decimal and using the integer format specifier.

Try this

lblsummary.Text = String.Format("Total hrs: {0:f}", hrtotalsTotal)
e.Row.Cells(2).Text = (hrtotalsTotal / 60).ToString("f")

Thanks


where can I get a list of the format specifier

Check this linkhttp://blog.g9th.com/2007/01/29/string-formats-in-c.aspx

Thanks

String.Format("{0:#.##}", 19.9)

How come the above comes out as 19.9 and not 19.90.as intended? Is there a way to add trailing zeros to the format? Thanks.

Hi,

Could you post a little bit more code?

My understanding is you can useSubstring()method to deal that. For example.

string str = 19.90;

Response.Write(str);

str = str.Substring(0,4);

Response.Write(str);

Result: 19.90

19.9

Try that.

String.Formatting a javascript code sample, how do I escape the { } characters?

Hi,

I'm trying to String.format a piece of javascript code

string.Format("function showalert(msg) { window.status = '{0}'; alert(msg); }", "Test");

This compiles ok but when it runs it has a Input string was not in a correct format exception as the '{' and '}' characters are reserved and used for substitution in the string.Format function.

Is there a way I can escape the '{}' characters so that the string.format function ignores them?

I've tried

string.Format("function showalert(msg) \{ window.status = '{0}'; alert(msg); \}", "Test");

which is normally how you escape but it dosen't work.

Thanks for your help

Auschucky

Hi ,To specify a single literal brace character informat, specify two leading or trailing brace characters; that is, "{{" or "}}".
string test =string.Format("function showalert(msg) {{ window.status = '{0}'; alert(msg); }}","Test");
Hope this helps , Gook Luck^_^
Ta, worked a treat

String.Format??

Hi everyone I have a textbox which acts like a counter. I want to format the
number in 4 digits; for instance,
1 -> 0001
10 -> 0010

Is there anyway I can do that?

ThanksTry

foo.ToString("0000").

Cheers,
B

"Hai Nguyen" <haiaggie@.neo.tamu.edu> wrote in message
news:O9rP95e5DHA.1936@.TK2MSFTNGP12.phx.gbl...
> Hi everyone I have a textbox which acts like a counter. I want to format
the
> number in 4 digits; for instance,
> 1 -> 0001
> 10 -> 0010
> Is there anyway I can do that?
> Thanks
Use PadLeft
if your textbox is named Textbox1:

Textbox1.Text.PadLeft
____________________________________
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
DigitallySmooth Inc. | Quick Site Studio
"Hai Nguyen" <haiaggie@.neo.tamu.edu> wrote in message news:O9rP95e5DHA.1936@.TK2MSFTNGP12.phx.gbl...
Hi everyone I have a textbox which acts like a counter. I want to format the
number in 4 digits; for instance,
1 -> 0001
10 -> 0010

Is there anyway I can do that?

Thanks
String.Format("{0:0000}", strMyString);

As always, at least 3 ways to do anything in MS code.

MIke

"Hai Nguyen" <haiaggie@.neo.tamu.edu> wrote in message
news:O9rP95e5DHA.1936@.TK2MSFTNGP12.phx.gbl...
> Hi everyone I have a textbox which acts like a counter. I want to format
the
> number in 4 digits; for instance,
> 1 -> 0001
> 10 -> 0010
> Is there anyway I can do that?
> Thanks

Monday, March 26, 2012

string.ToString (IFormatProvider) doesnt take case of the provider ?

It's seem like a bug in the framework... but I'm not sure...
It's must seems weird, but I have a string variable and I want to apply a format and get the string formatted in that format. My original string is a numeric value and I want to obtain a string formatted based on the culture of the current thread.
string numericValue = "1234.56";
string returnValue = numericValue.ToString (System.Globalization.NumberFormatInfo.CurrentInfo);
But, it doesn't work. So, I check the code in the framework and there two methods ToString on the string Object. And both, return the this even the one with the provider parameter.

publicstringToString(IFormatProvider provider){returnthis;}
I you agree with me that there is a bug in the framework ?

hello.
i think that you're seeing it the wrong way.
what you want to do is get your number (ex.: double) and use the ToString method of that struct.
Double num = ...;
num.ToString( provider );
i think that using tostring with a provider on a string doesn't make any sense...

What I am trying to do is converting the format of a string from one culture to another. Say that you have a string 1 234,56 on the french-Canada culture and want to format the string to the english-US culture. I can parse the string to double and returning back to string. But I see that the string class have a method ToString who take a FormatProvider and do nothing with the parameter.


hello.

what i was trying to say is that if you're supposed to have a number, then use a variable of the desired type to keep it and parse it to the desired culture.


My simple solution is:
private void Form1_Load(object sender, EventArgs e)
{
double i = 1234.56;
textBox1.Text = i.ToString("0,000.00");

}

Saturday, March 24, 2012

Strip HTML from Text

Is there an easy way to strip HTML tags from Text to get just the plain
text?
I am using a program called FreeTextBox that lets you format Text in a
TextBox. It does this by adding HTML tags (<b>, <u>,<span> etc) to the
code.
The problem is that it is a problem since I am putting the text in a
varChar(8000). The HTML adds a lot characters to the text. I can change
this to a Text field in Sql, but you can do a FullText search on a Text
field (plus I don't really want the tags in a Text Search).
Is there some filtering mechanism that would strip the HTML from a text
field?
Thanks,
TomHere's a complete sample :
http://www.experience247.com/srcvie...tmlIn.cs&font=3
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:%23UjtGFlPGHA.1580@.TK2MSFTNGP09.phx.gbl...
> Is there an easy way to strip HTML tags from Text to get just the plain te
xt?
> I am using a program called FreeTextBox that lets you format Text in a Tex
tBox. It does this by
> adding HTML tags (<b>, <u>,<span> etc) to the code.
> The problem is that it is a problem since I am putting the text in a varCh
ar(8000). The HTML adds
> a lot characters to the text. I can change this to a Text field in Sql, b
ut you can do a FullText
> search on a Text field (plus I don't really want the tags in a Text Search
).
> Is there some filtering mechanism that would strip the HTML from a text fi
eld?
> Thanks,
> Tom
>
That does what I was looking for.
Thanks,
Tom
"Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
news:OMXrAJlPGHA.4952@.TK2MSFTNGP09.phx.gbl...
> Here's a complete sample :
> http://www.experience247.com/srcvie...tmlIn.cs&font=3
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaol : http://asp.net.do/foros/
> ===================================
> "tshad" <tscheiderich@.ftsolutions.com> wrote in message
> news:%23UjtGFlPGHA.1580@.TK2MSFTNGP09.phx.gbl...
>

Strip HTML from Text

Is there an easy way to strip HTML tags from Text to get just the plain
text?

I am using a program called FreeTextBox that lets you format Text in a
TextBox. It does this by adding HTML tags (<b>, <u>,<span> etc) to the
code.

The problem is that it is a problem since I am putting the text in a
varChar(8000). The HTML adds a lot characters to the text. I can change
this to a Text field in Sql, but you can do a FullText search on a Text
field (plus I don't really want the tags in a Text Search).

Is there some filtering mechanism that would strip the HTML from a text
field?

Thanks,

TomHere's a complete sample :

http://www.experience247.com/srcvie...tmlIn.cs&font=3

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"tshad" <tscheiderich@.ftsolutions.com> wrote in message
news:%23UjtGFlPGHA.1580@.TK2MSFTNGP09.phx.gbl...
> Is there an easy way to strip HTML tags from Text to get just the plain text?
> I am using a program called FreeTextBox that lets you format Text in a TextBox. It does this by
> adding HTML tags (<b>, <u>,<span> etc) to the code.
> The problem is that it is a problem since I am putting the text in a varChar(8000). The HTML adds
> a lot characters to the text. I can change this to a Text field in Sql, but you can do a FullText
> search on a Text field (plus I don't really want the tags in a Text Search).
> Is there some filtering mechanism that would strip the HTML from a text field?
> Thanks,
> Tom
That does what I was looking for.

Thanks,

Tom
"Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
news:OMXrAJlPGHA.4952@.TK2MSFTNGP09.phx.gbl...
> Here's a complete sample :
> http://www.experience247.com/srcvie...tmlIn.cs&font=3
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaol : http://asp.net.do/foros/
> ===================================
> "tshad" <tscheiderich@.ftsolutions.com> wrote in message
> news:%23UjtGFlPGHA.1580@.TK2MSFTNGP09.phx.gbl...
>> Is there an easy way to strip HTML tags from Text to get just the plain
>> text?
>>
>> I am using a program called FreeTextBox that lets you format Text in a
>> TextBox. It does this by adding HTML tags (<b>, <u>,<span> etc) to the
>> code.
>>
>> The problem is that it is a problem since I am putting the text in a
>> varChar(8000). The HTML adds a lot characters to the text. I can change
>> this to a Text field in Sql, but you can do a FullText search on a Text
>> field (plus I don't really want the tags in a Text Search).
>>
>> Is there some filtering mechanism that would strip the HTML from a text
>> field?
>>
>> Thanks,
>>
>> Tom
>>

Stripping the time portion from date field

Hi all
I've got a textbox on the web page that captures a date.
When an insert is done, the information captured into the database is of the format dd/mm/yyyy hh:mm:ss.
How do I strip the time portion and save only the date part into the database ?
I'm using a formview, sqldatasource controls for this web page.
I tried the following in formview iteminserting event:
Dim culture_2 As System.Globalization.CultureInfo = New CultureInfo("en-GB", True)
Dim wAcceptanceD As TextBox = CType(FormView1.Row.FindControl("dtAcceptDTextBox"), TextBox)
e.Values.Add("dtAcceptD", DateTime.Parse(wAcceptanceD.Text, culture_2, DateTimeStyles.NoCurrentDateDefault))

When I run the web page, I get the following error:

System.ArgumentException was unhandled by user code
Message="Item has already been added. Key in dictionary: 'dtAcceptD' Key being added: 'dtAcceptD'"
Source="mscorlib"
StackTrace:
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

at System.Collections.Hashtable.Add(Object key, Object value)

at System.Collections.Specialized.OrderedDictionary.Add(Object key, Object value)

at Default3.FormView1_ItemInserting(Object sender, FormViewInsertEventArgs e) in C:\SRS\Default3.aspx.vb:line 12

at System.Web.UI.WebControls.FormView.OnItemInserting(FormViewInsertEventArgs e)

at System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation)

at System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)

at System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e)

at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)

at System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e)

at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)

at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)

at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)

at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Can someone pleaseeeeeeeeeeeeeeeee tell me what's wrong ?
TIA.

The problem here is not the date parsing. Well, it is a problem too but not the one you're seeing.
You're using always the same key in your dictionary: "dtAcceptD". The first time it's ok, the second time, it crashes with the error you're seeing. A dictionary can have only one entry with a given key.
As for date parsing, you should specify the date format you're expecting explicitly. There is an overload of ParseExact that takes a format string.
Once you've gotten a DateTime object, it's easy to strip the time part (but why are you asking for it if you're going to throw it away? ) by constructing a new date object from the parts of the old one, something like:
new DateTime(myDate.Year, myDate.Month, myDate.Day)

Hi
Thanks for your reply.
Realised the following:
1) SQL saves the information for a datetime field with date and time information.
2) Viewing the information from the following sources have different results:
From SQL Enterprise Manager, information displayed as dd/mm/yyy.
From SQL Query Analyzer, information displayed as yyyy-mm-dd 00:00:00.
From VS (via the Database Explorer), its displayed as dd/mm/yyyy 12:00:00.
I probably dont need to do any conversion in the ItemInserting event of the formview.
Thanks for the tip on stripping the time portion of a datetime object. I'm sure it will come in handy.

Stripping the format of files.

Hi Guys,

I am fairly new to asp.net but am embarking on a project based on asp.net I am wondering if anyone has any experience or knowledge on how to strip the formatting of different documents? Maybe for a start, how do you strip the formatting of styles and stuff in MS Words to just purely text?

Regards,

Raymond

Hi,

if you mean that you just want to get the text itself and not the colors, ... you can copy paste it into notepad and from notepad copy paste to somewhere else.

Grz, Kris.


Hi Kris,

Thanks for your input. Actually I am looking more at the coding level because I need to strip the formatting of the file automatically before I can do further comparing of the contents in string or text format.

Regards,
Raymond


Is there anyone with the relevant experience who can share their knowledge?

Thanks!

Raymond