Main Page | Report this Page
.NET DotNet Forum Index  »  ASP.NET Forum  »  updating mysql table from gridview date field...
Page 1 of 1    

updating mysql table from gridview date field...

Author Message
J...
Posted: Wed Oct 28, 2009 11:18 pm
Guest
My gridview is bound to a Mysql table using a sqldatasource. It works fine
except I want to be able to edit a date field. I want to display and edit
in mm/dd/yyyy format. The problem is that Mysql expect the date data to be
in yyyy-mm-dd format. The following displays and edits as I'd like but I
get an error when updating (unless I type it in yyyy-mm-dd format). Thanks!

<asp:TemplateField HeaderText="expires date" SortExpression="code_1">
<ItemTemplate>
<asp:Label runat="server" ID="lblexpires_date"
Text='<%#Bind("expires_date","{0:d}") %>'></asp:Label>
</ItemTemplate>

<EditItemTemplate>
<asp:TextBox runat="server" ID="txtexpires_date"
Text='<%#Bind("expires_date","{0:d}") %>'></asp:TextBox>
</EditItemTemplate>

<ItemStyle Width="100px" />
</asp:TemplateField>
 
Gregory A. Beamer...
Posted: Thu Oct 29, 2009 12:27 pm
Guest
"J" <nobody at (no spam) nowhere.com> wrote in
news:cdmdnTKi4bY_uHTXnZ2dnUVZ_gidnZ2d at (no spam) posted.nuvoxcommunications:

Quote:
My gridview is bound to a Mysql table using a sqldatasource. It works
fine except I want to be able to edit a date field. I want to display
and edit in mm/dd/yyyy format. The problem is that Mysql expect the
date data to be in yyyy-mm-dd format. The following displays and
edits as I'd like but I get an error when updating (unless I type it
in yyyy-mm-dd format). Thanks!

Drop the drag and drop garbage and build your own bits to grab the data
and transform the date to the string format MySQL expects. The ToString
() method has different date formats. If none work for you, then you can
use a culture that has the format as their default and use a standard
ToDateString().

Note, also, that you might be able to send the date back to MySQL as a
date if you can the drag and drop bits. i have not touched MySQL in
ages, so I cannot advise on MySQL.

Peace and Grace,



--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: at (no spam) gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
J...
Posted: Fri Oct 30, 2009 7:09 am
Guest
Gregory, I understand that I could use a dataset to retrieve and update
records, and bind to the gridview. My intent here is to fully use the
built-in functionality of the gridview, to learn it, and see how far I can
get with it. It's not yet crystal clear exactly how #Bind works. I was
hoping I could use #Bind with a custom method to get what I needed.


"Gregory A. Beamer" <NoSpamMgbworld at (no spam) comcast.netNoSpamM> wrote in message
news:Xns9CB388A58CD8Bgbworld at (no spam) 207.46.248.16...
Quote:
"J" <nobody at (no spam) nowhere.com> wrote in
news:cdmdnTKi4bY_uHTXnZ2dnUVZ_gidnZ2d at (no spam) posted.nuvoxcommunications:

My gridview is bound to a Mysql table using a sqldatasource. It works
fine except I want to be able to edit a date field. I want to display
and edit in mm/dd/yyyy format. The problem is that Mysql expect the
date data to be in yyyy-mm-dd format. The following displays and
edits as I'd like but I get an error when updating (unless I type it
in yyyy-mm-dd format). Thanks!

Drop the drag and drop garbage and build your own bits to grab the data
and transform the date to the string format MySQL expects. The ToString
() method has different date formats. If none work for you, then you can
use a culture that has the format as their default and use a standard
ToDateString().

Note, also, that you might be able to send the date back to MySQL as a
date if you can the drag and drop bits. i have not touched MySQL in
ages, so I cannot advise on MySQL.

Peace and Grace,



--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: at (no spam) gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Gregory A. Beamer...
Posted: Fri Oct 30, 2009 12:30 pm
Guest
"J" <nobody at (no spam) nowhere.com> wrote in
news:L96dnRYNINgHeHfXnZ2dnUVZ_q2dnZ2d at (no spam) posted.nuvoxcommunications:

Quote:
Gregory, I understand that I could use a dataset to retrieve and
update records, and bind to the gridview. My intent here is to fully
use the built-in functionality of the gridview, to learn it, and see
how far I can get with it. It's not yet crystal clear exactly how
#Bind works. I was hoping I could use #Bind with a custom method to
get what I needed.

I have nothing against learning what the IDE has to offer, but it is still
very easy to step outside of the box MS has painted. When you find that
point, it is easier to add a bit of custom code and move on. Good luck!

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: at (no spam) gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Mon Nov 23, 2009 6:16 am