Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 30, 2012 09:07 AM by vicky1
Contributor
5129 Points
956 Posts
Nov 29, 2012 08:17 AM|LINK
Use this code
ddlEcat.SelectedValue = objDs.Tables(0).Rows(0)("Emp_cat") == DBNull.Value ? "-- Select --" : objDs.Tables(0).Rows(0)("Emp_cat");
Member
32 Points
349 Posts
Nov 29, 2012 09:02 AM|LINK
hi chaaran,
thanks for response
it's working fine.
one last question
txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString());
in this code it's getting value date with time and i want only date in dd/MM/yyyy format.
how to get this format?
thanks
Star
13599 Points
2691 Posts
Nov 29, 2012 09:11 AM|LINK
Hi,
string formatted = date.ToString("dd-MM-yyyy");
will do it.
Here is a good reference for different formats
Nov 29, 2012 09:15 AM|LINK
hi ,
this code i know but how to set this with this code?
Nov 29, 2012 09:22 AM|LINK
Change the following line
vicky1 txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString());
as
txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString("dd/MM/yyyy"));
Nov 29, 2012 09:27 AM|LINK
hi,
this i checked before but getting error:
that is, No overload method for 'ToString' takes '1' argument.
Nov 29, 2012 09:37 AM|LINK
select convert(varchar(30),DOB,103) as DOB from YourTableName
it will return the date in dd/MM/yyyy format no need to do anything on code behind
Nov 29, 2012 09:40 AM|LINK
that i know query to convert in that format but how to use that in this code
can you set your code in this code?
All-Star
30184 Points
4906 Posts
Nov 29, 2012 09:49 AM|LINK
I always use this converter-
http://www.developerfusion.com/tools/
Nov 29, 2012 09:50 AM|LINK
only this converter i am using ok?
Raigad
Contributor
5129 Points
956 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 08:17 AM|LINK
Use this code
ddlEcat.SelectedValue = objDs.Tables(0).Rows(0)("Emp_cat") == DBNull.Value ? "-- Select --" : objDs.Tables(0).Rows(0)("Emp_cat");
Mark as Answer, if the post helped you...
Visit My Blog
vicky1
Member
32 Points
349 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:02 AM|LINK
hi chaaran,
thanks for response
it's working fine.
one last question
txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString());
in this code it's getting value date with time and i want only date in dd/MM/yyyy format.
how to get this format?
thanks
sarathi125
Star
13599 Points
2691 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:11 AM|LINK
Hi,
string formatted = date.ToString("dd-MM-yyyy");
will do it.
Here is a good reference for different formats
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
vicky1
Member
32 Points
349 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:15 AM|LINK
hi ,
this code i know but how to set this with this code?
txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString());
thanks
sarathi125
Star
13599 Points
2691 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:22 AM|LINK
Hi,
Change the following line
as
txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString("dd/MM/yyyy"));
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
vicky1
Member
32 Points
349 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:27 AM|LINK
hi,
this i checked before but getting error:
that is, No overload method for 'ToString' takes '1' argument.
thanks
Raigad
Contributor
5129 Points
956 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:37 AM|LINK
select convert(varchar(30),DOB,103) as DOB from YourTableName
it will return the date in dd/MM/yyyy format no need to do anything on code behind
Mark as Answer, if the post helped you...
Visit My Blog
vicky1
Member
32 Points
349 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:40 AM|LINK
hi,
that i know query to convert in that format but how to use that in this code
txtDOB.Text = ((objDs.Tables[0].Rows[0]["DOB"]) == DBNull.Value? "" : objDs.Tables[0].Rows[0]["DOB"].ToString());
can you set your code in this code?
thanks
asteranup
All-Star
30184 Points
4906 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:49 AM|LINK
Hi,
I always use this converter-
http://www.developerfusion.com/tools/
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
vicky1
Member
32 Points
349 Posts
Re: How to use this vb code in c#?
Nov 29, 2012 09:50 AM|LINK
hi,
only this converter i am using ok?
thanks