ZopoStyle

Hi,

I have a datetimepicker control, that when I define a value to save in the datebase it's save correctly, but when I get result to set to the control, it does not shows the value that I selected but the default value ! I've already get the value that is query from the database and it's getting correctly in datetime type

How can I solve it

Thanks (PS: Sorry for my english)




Re: Windows Forms General Set Datetime Value - Datepicker

Mark Dawson

Hi,

are you setting the Value property of the DateTimePicker control Can you post a short code sample that shows your problem

Mark.






Re: Windows Forms General Set Datetime Value - Datepicker

ZopoStyle

yes,

here is the code

dtDOB.Value = addressdata.DOB;

and the addressdata.DOB returns "30/9/1983 00:00:00" as datetime...

but if I change the value, and reload from the data base it does not get the new value...

It's the same funtion that does the work...

private void LoadCurrentItem()

{

if ( grdAddress.CurrentRowIndex == -1 ) // Is there any row selected now

{

btnEdit.Enabled = false;

btnDelete.Enabled = false;

return;

}

int Id = int.Parse ( grdAddress[grdAddress.CurrentRowIndex, 4].ToString() );

AddressData addressdata = AddressDataManager.GetAddressData( Id );

if ( addressdata == null )

{

MessageBox.Show ( "Nao foi possivel consultar os dados do item selecionado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error );

return;

}

txtName.Text = addressdata.Name;

txtAddress.Text = addressdata.Address;

txtCEP.Text = addressdata.CEP;

txtCidade.Text = addressdata.Cidade;

txtOtherDetails.Text = addressdata.Remarks;

txtBairro.Text = addressdata.Bairro;

txtTelefone.Text = addressdata.Telefone;

txtMailId.Text = addressdata.Email;

txtCelular.Text = addressdata.Celular;

dtDOB.Value = addressdata.DOB;

}

Thanks






Re: Windows Forms General Set Datetime Value - Datepicker

Mark Dawson

Is it possible your function is exiting at one of the return statements, before the value is set

Mark.






Re: Windows Forms General Set Datetime Value - Datepicker

ZopoStyle

No, It's strange isn't it

I tryied to go step by step, and it runs normally....I've also tryed to use a message box to show the value before and after I set, and it returns the correct value...it just don't show it...

I've put a this.refresh..and doesn't solved...






Re: Windows Forms General Set Datetime Value - Datepicker

Friendly Dog

After you changed the value in the control, are you sure you saved the new value in database Can you verify if the value in database is changed




Re: Windows Forms General Set Datetime Value - Datepicker

ZopoStyle

Yes, I accessed it manually, and its ok,.....If it was wrong it will also appear in the messagebox....

Do you have MSN I can share my desktop with you so you can see it....