Belinda
Belinda

Reputation: 116

How can i Convert the DatePicker Input to string

I am using the following Codes to get the date from the date picker

objDD_ml.EffDate=(DirectCast(drv.Cells(3).FindControl("rdpEffDate"), RadDatePicker).DateInput).ToString

But it does not return the date... It returns like 'DateInput'

How can i use the code to get the value for Effdate as a correct format of date

Anyone please help me..

Upvotes: 0

Views: 237

Answers (2)

Dilip Suvagiya
Dilip Suvagiya

Reputation: 394

Whenever you want date into string and in specific format you can always apply following :

objDD_ml.EffDate = (
    DirectCast(drv.Cells(3).FindControl("rdpEffDate"), RadDatePicker).DateInput
).ToString("dd/MM/yyyy")

Upvotes: 1

Atanu Roy
Atanu Roy

Reputation: 1394

Try to cast the FindControl object into the corresponding ASP control externally. Then access the value of that control and convert it to .ToString

I don't know what control you are using, but it should be something like below -

objDD_ml.EffDate = ((RadDatePicker)(drv.Cells[i].FindControl("rdpEffDate")).SelectedDate.Tostring;

Upvotes: 0

Related Questions