this
.txtCommission.Text = (decimal)_SalesPersonToEdit["Default Commission"];
How do i convert this string to a Decimal, I have tried using ToString() but that does not work and I also tried to use Convert.ToDecimal(string) = object....and that didnt work eithier any help on this situation! thanks!

Convert Decimal to String???
Sweeps78
ChKa
well everything there you are putting it into a textbox therefore everything needs to be done into a string which you pretty much have done. I don't see anywhere where you are needing to convert a value to a decimal. Anything that needs to be placed into a string type needs that object to be converted to string using the .ToString() at the end:
this.txtCommission.Text = _SalesPersonToEdit["Default Commission"].ToString();
MikeBzz
dudeness
re infecta
but the line i posted - no where does it convert to decimal. It may well be producing an error from some other place.
you could also try:
this.txtCommission.Text = Convert.ToString(_SalesPersonToEdit["Default Commission"]);
SMaia
private void LoadSalesRowObjectToForm(System.Data.DataRow SalesPersonToEdit)
{
try {
_SalesPersonToEdit = SalesPersonToEdit;
int i;
for(i=2; i<_SalesPersonToEdit.Table.Columns.Count; i++)
{
if( i < _SalesPersonToEdit.Table.Columns.Count-1)
{
if(_SalesPersonToEdit.IsNull(i))
_SalesPersonToEdit
}
else {
if(_SalesPersonToEdit.IsNull(i))
_SalesPersonToEdit
}
}
this.cboTitle.Text = (string)_SalesPersonToEdit["Title"];
this.txtCity.Text = (string)_SalesPersonToEdit["City"];
this.txtFirstName.Text = (string)_SalesPersonToEdit["First Name"];
this.txtLastName.Text = (string)_SalesPersonToEdit["Last Name"];
this.cboState.Text = (string)_SalesPersonToEdit["State"];
this.txtTelephone.Text = (string)_SalesPersonToEdit["CoPhone"];
this.txtPagerNumber.Text = (string)_SalesPersonToEdit["Pager"];
this.txtMobileNumber.Text = (string)_SalesPersonToEdit["Mobile Phone"];
this.txtEmail.Text = (string)_SalesPersonToEdit["E-Mail"];
this.txtExtension.Text = (string)_SalesPersonToEdit["CoExtension"];
this.txtFaxNumber.Text = (string)_SalesPersonToEdit["Fax"];
//this.txtCommission.Text = (decimal)_SalesPersonToEdit["Default Commission"]; this.txtNotes.Text = (string)_SalesPersonToEdit["Notes"];
wilson_carol999
Actually i didnt need "(decimal)" in my code and it worked i guess when using that row of a datset i dont need to declare its type to bind it to the form.. but i did add the ToString() method though it looked like this
this.txtCommission.Text = _SalesPersonToEdit["Default Commission"].ToString(); thanks 4 the help!johnny83
what "doesnt work" you need to be specific :-)
to convert a string to a decimal:
decimal theDecimal = Convert.ToString(theString);
however you need to be sure in some way that the value is a "qualified" decimal value in other words, integer values only generally
trelaw
cisco0407
*confused*
can you show the entire code block you are using As well as this, what do you mean by "assign that text back to my row of data in my Sql Table" you can't read and write at the same time if you are using a SqlDataReader...a SqlDataReader is only a fast forward only reader
Osmose1000