Showing posts with label below. Show all posts
Showing posts with label below. Show all posts

Saturday, March 31, 2012

text box and SqlDecimal datatypes

Hi all, I have a DAL which takes in a value as shown below ready for my
MSSQL stored procedure.

protected SqlDecimal _annualLeave = SqlDecimal.Null;
public SqlDecimal AnnualLeave
{

get {return _annualLeave;}

set{ _annualLeave = value;}

}

I have a problem where when I try to pass in information from a textbox on a
ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!

I thought I could just go..

((System.Data.SqlDecimal)AnnualLeave.Text)

Where AnnualLeave.Text is the value of my textbox on my form, but I received
"Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
(Which is fair enough)

So, I tried

((System.Data.SqlDecimal)(Convert.ToDecimal(Annual Leave.Text))

but for some reason, this rounds the number to an integer!! e.g. 12.2
becomes 12!!!!!

Can someone please tell me what am I doing wrong here, it's been a long day
:P

Thanks
MarkHi Mark,

just use Convert.ToDecimal(AnnualLeave.Text)

HTH,

"Mark" <mark@.Z-Zvolution.nZt> wrote in message
news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> Hi all, I have a DAL which takes in a value as shown below ready for my
> MSSQL stored procedure.
> protected SqlDecimal _annualLeave = SqlDecimal.Null;
> public SqlDecimal AnnualLeave
> {
> get {return _annualLeave;}
> set{ _annualLeave = value;}
> }
> I have a problem where when I try to pass in information from a textbox on
> a
> ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
> I thought I could just go..
> ((System.Data.SqlDecimal)AnnualLeave.Text)
> Where AnnualLeave.Text is the value of my textbox on my form, but I
> received
> "Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
> (Which is fair enough)
> So, I tried
> ((System.Data.SqlDecimal)(Convert.ToDecimal(Annual Leave.Text))
> but for some reason, this rounds the number to an integer!! e.g. 12.2
> becomes 12!!!!!
> Can someone please tell me what am I doing wrong here, it's been a long
> day
> :P
> Thanks
> Mark
Hi Onin, I was actually doing this originally and still get the same
problem.

Thanks for your advice
Cheers
Mark
"Onin Tayson" <Leon_Tayson@.compaid.com> wrote in message
news:O%23qlxt44FHA.1140@.tk2msftngp13.phx.gbl...
> Hi Mark,
> just use Convert.ToDecimal(AnnualLeave.Text)
> HTH,
> "Mark" <mark@.Z-Zvolution.nZt> wrote in message
> news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> > Hi all, I have a DAL which takes in a value as shown below ready for my
> > MSSQL stored procedure.
> > protected SqlDecimal _annualLeave = SqlDecimal.Null;
> > public SqlDecimal AnnualLeave
> > {
> > get {return _annualLeave;}
> > set{ _annualLeave = value;}
> > }
> > I have a problem where when I try to pass in information from a textbox
on
> > a
> > ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
> > I thought I could just go..
> > ((System.Data.SqlDecimal)AnnualLeave.Text)
> > Where AnnualLeave.Text is the value of my textbox on my form, but I
> > received
> > "Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
> > (Which is fair enough)
> > So, I tried
> > ((System.Data.SqlDecimal)(Convert.ToDecimal(Annual Leave.Text))
> > but for some reason, this rounds the number to an integer!! e.g. 12.2
> > becomes 12!!!!!
> > Can someone please tell me what am I doing wrong here, it's been a long
> > day
> > :P
> > Thanks
> > Mark

text box and SqlDecimal datatypes

Hi all, I have a DAL which takes in a value as shown below ready for my
MSSQL stored procedure.
protected SqlDecimal _annualLeave = SqlDecimal.Null;
public SqlDecimal AnnualLeave
{
get {return _annualLeave;}
set{ _annualLeave = value;}
}
I have a problem where when I try to pass in information from a textbox on a
ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
I thought I could just go..
((System.Data.SqlDecimal)AnnualLeave.Text)
Where AnnualLeave.Text is the value of my textbox on my form, but I received
"Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
(Which is fair enough)
So, I tried
((System.Data.SqlDecimal)(Convert.ToDecimal(AnnualLeave.Text))
but for some reason, this rounds the number to an integer!! e.g. 12.2
becomes 12!!!!!
Can someone please tell me what am I doing wrong here, it's been a long day
:P
Thanks
MarkHi Mark,
just use Convert.ToDecimal(AnnualLeave.Text)
HTH,
"Mark" <mark@.Z-Zvolution.nZt> wrote in message
news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
> Hi all, I have a DAL which takes in a value as shown below ready for my
> MSSQL stored procedure.
> protected SqlDecimal _annualLeave = SqlDecimal.Null;
> public SqlDecimal AnnualLeave
> {
> get {return _annualLeave;}
> set{ _annualLeave = value;}
> }
> I have a problem where when I try to pass in information from a textbox on
> a
> ASP.NET page OR Winform the *damn* thing gets rounded to an Integer!
> I thought I could just go..
> ((System.Data.SqlDecimal)AnnualLeave.Text)
> Where AnnualLeave.Text is the value of my textbox on my form, but I
> received
> "Cannot convert type 'string' to 'System.Data.SqlTypes.SqlDecimal" error
> (Which is fair enough)
> So, I tried
> ((System.Data.SqlDecimal)(Convert.ToDecimal(AnnualLeave.Text))
> but for some reason, this rounds the number to an integer!! e.g. 12.2
> becomes 12!!!!!
> Can someone please tell me what am I doing wrong here, it's been a long
> day
> :P
> Thanks
> Mark
>
Hi Onin, I was actually doing this originally and still get the same
problem.
Thanks for your advice
Cheers
Mark
"Onin Tayson" <Leon_Tayson@.compaid.com> wrote in message
news:O%23qlxt44FHA.1140@.tk2msftngp13.phx.gbl...
> Hi Mark,
> just use Convert.ToDecimal(AnnualLeave.Text)
> HTH,
> "Mark" <mark@.Z-Zvolution.nZt> wrote in message
> news:OQXlCD24FHA.2364@.TK2MSFTNGP12.phx.gbl...
on
>

Wednesday, March 28, 2012

Text element's width is too wide when doctype is set to XHTML

I've read a bunch of posts on this and none of the answers are
legitimate (IMHO) so I thought I'd throw it out there again.

Using the html code below, if you set the doctype to HTML 4.0, and
view the page in IE 6 or 7, the text element fills the table cell
perfectly.
If you change the doctype to XHTML 1.0, the text element extends
beyond the width of the table cell.
On the other hand, if you view the page in FireFox, the page displays
perfectly regardless of which doctype you use.

I'm really looking for a better solution than to set the doctype to
HTML 4.0. Or perhaps is this just another anomaly in IE?

Please note that I have included both doc type headers. The first
doctype header is always used so just reverse the order to try each
one out.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table>
<tr>
<td width="200">
<input type="text" style="width:100%" />
</td>
</tr>
</table>
</body>
</html>you just need to understand html 4.0. object have a width, border and
margin. the border and margin extend beyond the width. so if you make an
object 100px wide with a 2px margin and a 2px border it will be 108px
wide. if you make the width 100% (of the parent), with margin and border
it will be 8px wider than the parent. now if the parent has padding the
control is offset and will extend beyond the parent unless overflow is set.

because you are not setting the borders, margins, and padding, you get
the default, which differs by browser.

-- bruce (sqlwork.com)

mszanto@.hotmail.com wrote:

Quote:

Originally Posted by

I've read a bunch of posts on this and none of the answers are
legitimate (IMHO) so I thought I'd throw it out there again.
>
Using the html code below, if you set the doctype to HTML 4.0, and
view the page in IE 6 or 7, the text element fills the table cell
perfectly.
If you change the doctype to XHTML 1.0, the text element extends
beyond the width of the table cell.
On the other hand, if you view the page in FireFox, the page displays
perfectly regardless of which doctype you use.
>
I'm really looking for a better solution than to set the doctype to
HTML 4.0. Or perhaps is this just another anomaly in IE?
>
Please note that I have included both doc type headers. The first
doctype header is always used so just reverse the order to try each
one out.
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table>
<tr>
<td width="200">
<input type="text" style="width:100%" />
</td>
</tr>
</table>
</body>
</html>
>


I've done a bit more research, and understand what you mean, but that
that really only applies for XHTML doctypes. HTML doc types
automatically take these other factors into account when determining
the display width of an object whose style width is set to 100%.

Apparently XHTML uses a strict box model which really causes a lot of
aggravation when laying out a web page. Another example being that you
can't set the height of a Table inline, you have to set it in the
style sheet. I'm okay with that as long as the XHTML doctype is used
in the appropriate situations.

Having said all that, why oh why did Microsoft decide to set the
default doctype to XHTML for new WebForms in VS 2005. That is
completely idiotic considering the aggravation it will cause for the
majority of developers.

mike

Monday, March 26, 2012

Text if not null

I want to display text in a datagrid based on if the text pulled in from the database is null or not.

Below I can change the backcolor if its not blank but I want to change the text :

Put "Confirmed" if it is not null, and "Not Confirmed" if it is null.

Dim conf As String
conf = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "confirm_id"))

If conf <> "" Then
e.Item.BackColor = System.Drawing.Color.AliceBlue

End If

How can I do this?Try (3 is just an example, you'll have to use the right column index)
e.Item.Cells[3].Text = "Confirmed"

Regards
Fredr!k
I got the following error:
'Cells' is not a member of 'System.Web.UI.WebControls.DataListItem'.

I am using a datalist is there a way of doing this with a datalist?