List Info

Thread: Re: Re: gridview question




Re: Re: gridview question
user name
2007-01-30 14:50:03
DateTime.ParseExact("22/1/2007",
"dd/MM/yyyy", new
System.Globalization.CultureInfo("en-GB"))

this will parse the date that you are providing.  Replace
the culture info with whatever culture you need.
 
Dwayne



----- Original Message ----
From: OwaiZ <owaiz_vaiyanihotmail.com>
To: AspNetAnyQuestionIsOk@yahoogroups.com
Sent: Tuesday, January 30, 2007 2:42:00 PM
Subject: [AspNetAnyQuestionIsOk] Re: gridview question

it happens when i try to update the date forexample from
01/01/2007 
to 22/01/2007, and then click update link
if you have this working could you please send it to me? 
owaiz_vaiyani hotmail.com

regards,
Owais

--- In AspNetAnyQuestionIs Okyahoogroups. com,
"Dean Fiala" 
<dfiala...> wrote:
>
> where is this happening?
> 
> On 1/30/07, OwaiZ <owaiz_vaiyani ...>
wrote:
> >
> > hi
> > the error is
> >
> > Arithmetic overflow error converting expression to
data type 
datetime.
> > The statement has been terminated.
> >
> > when i change date from 02/01/2007 to 22/01/2007
> >
> > which is bcoz of it not changing dd/mm/yyyy to
mm/dd/yyyy
> >
> > --- In 
AspNetAnyQuestionIs Okyahoogroups. com<AspNetAnyQuestionI
sOk%
40yahoogroups. com>,
> > "Dean Fiala"
> > <dfiala> wrote:
> > >
> > > what is not working?
> > >
> > > Is it throwing an error?
> > >
> > > If so, what's the error?
> > >
> > >
> > >
> > > On 1/30/07, OwaiZ <owaiz_vaiyani >
wrote:
> > > >
> > > > Thanks again for your help.
> > > > I am still struggling for it to work, is
it working there?
> > > > this is what i have got
> > > >
> > > > aspx
> > > > ----
> > > > <asp:GridView
ID="GridView1" 
OnRowUpdating= "OnRowUpdate_ Method"
> > > > runat="server"
AutoGenerateColumns ="False"
> > > > DataSourceID=
"SqlDataSource1"
> > DataKeyNames= "appointmentCust
omerId">
> > > > <Columns>
> > > > <asp:CommandField ShowEditButton=
"True" />
> > > > <asp:BoundField
DataField="appointm entCustomerId"
> > > > HeaderText=" appointmentCusto
merId"
> > > > SortExpression= "appointmentCust
omerId" />
> > > > <asp:BoundField
DataField="appointm entDateStamp"
> > > > DataFormatString= "{0:dd/MM/
yyyy}"
> > > > HeaderText=" appointmentDateS
tamp"
> > > > HtmlEncode=" False"
SortExpression= "appointmentDate Stamp"
> > > > ApplyFormatInEditMo de="True"
/>
> > > > </Columns>
> > > > </asp:GridView>
> > > > <asp:SqlDataSource
ID="SqlDataSource1" runat="server"
> > > > ConnectionString= "<%$ 
ConnectionStrings: CMLServerConnect ionString
> > %>"
> > > > SelectCommand= "SELECT
appointmentCustomer Id,
> > > > appointmentDateStam p FROM
appointments"
> > > > UpdateCommand= "UPDATE appointments
SET
> > > > appointmentDateStam p = appointmentDateSta mp WHERE
> > > > (appointmentCustome rId = appointmentCustome rId)">
> > > > <UpdateParameters>
> > > > <asp:Parameter
Name="appointmentDa teStamp" />
> > > > </UpdateParameters>
> > > > </asp:SqlDataSource >
> > > >
> > > > c#
> > > > --
> > > >
> > > > public void OnRowUpdate_ Method(object
sender,
> > GridViewUpdateEvent Args
> > > > e)
> > > > {
> > > > DateConverterClass dcc = new
DateConverterClass( );
> > > > String NewDate = e.NewValues[
"appointmentDate Stamp"].ToString
> > > > ();
> > > > String ConvertedDate =
dcc.ConvertDateForm at(NewDate) ;
> > > > SqlDataSource1. UpdateParameters
> > > > ["appointmentDateSt
amp"].DefaultVal ue
> > > > = ConvertedDate;
> > > > }
> > > >
> > > > --- In
> > AspNetAnyQuestionIs Okyahoogroups.
com<AspNetAnyQuestionI sOk%
40yahoogroups. com>
> > <AspNetAnyQuestionI sOk%
> > 40yahoogroups. com>,
> > > > "Dean Fiala"
> > > > <dfiala> wrote:
> > > > >
> > > > > You'd have call this code from the
RowUpdating event or 
another
> > > > method.
> > > > > There is no way I can see to do
this simply with declarative
> > > > programming.
> > > > > Set the OnRowUpdating parameter
like so
> > > > >
> > > > > <asp:GridView
ID="GridView1" runat="server"
> > > > > OnRowUpdating= "GridView1_
RowUpdating"
> > AutoGenerateEditBut ton="true"
> > > > > DataKeyNames=
"CustomerID" >
> > > > >
> > > > >
> > > > > to tell the grid what method to use
and then add the event 
to
> > your
> > > > code
> > > > > behind
> > > > >
> > > > > protected void GridView1_RowUpdati
ng(object sender,
> > > > GridViewUpdateEvent Args
> > > > > e)
> > > > > {
> > > > > //code here
> > > > > }
> > > > >
> > > > > On 1/30/07, OwaiZ
<owaiz_vaiyani > wrote:
> > > > > >
> > > > > > hi
> > > > > > thanks for your reply.
> > > > > >
> > > > > > where would i put this there
is no code for this in c#. I 
am
> > only
> > > > > > using gridview's update button
to change the date.
> > > > > >
> > > > > > --- In
> > > > AspNetAnyQuestionIs Okyahoogroups. com<AspNetAnyQuestionI sOk%
40yahoogroups. com>
> > <AspNetAnyQuestionI sOk%
> > 40yahoogroups. com>
> > > > <AspNetAnyQuestionI sOk%
> > > > 40yahoogroups. com>,
> > > > > > "Dean Fiala"
> > > > > > <dfiala>
wrote:
> > > > > > >
> > > > > > > In your update command
you need to format the parameter
> > value
> > > > > > >
> > > > > > > DateTime EnteredDate =
DateTime.Parse( e.NewValues
> > > > > > ["appointmentDate"
]);
> > > > > > >
> > > > > > >
> > > > > > > SqlDataSource2.
UpdateParameters
> > ["appointmentDate" ].DefaultValue
> > > > =
> > > > > > > EnteredDate. ToString(
"MM-dd-yyyy" );
> > > > > > >
> > > > > > > On 1/29/07, OwaiZ
<owaiz_vaiyani > wrote:
> > > > > > > >
> > > > > > > > Hi
> > > > > > > > Thanks for your
reply. I know how to parse datetime 
as dd-
> > mm-
> > > > yyyy
> > > > > > in
> > > > > > > > c#, I wanted to know
how to do that in gridview 
control,
> > when
> > > > I am
> > > > > > > > updating a date
using edit button.
> > > > > > > >
> > > > > > > > the gridview uses
the following :
> > > > > > > >
> > > > > > > >
<asp:SqlDataSource ID="SqlDataSource2"
runat="server"
> > > > > > > > ConnectionString=
"<%$ ConnectionStrings: String1 %>"
> > > > > > > > SelectCommand=
"SELECT [appointmentDate] ,
> > > > > > > > [appointmentCustome
rId] FROM [appointments] WHERE
> > > > > > > > ([appointmentCustom
erId] = appointmentCustome rId)"
> > > > > > > >
> > > > > > > > UpdateCommand=
"UPDATE appointments SET 
appointmentDate =
> > > > > > > > appointmentDate WHERE (appointmentCustome rId =
> > > > > > > > appointmentCustome rId)">
> > > > > > > >
<SelectParameters>
> > > > > > > >
<asp:FormParameter FormField="DetailsC ustId"
> > > > > > > >
Name="appointmentCu stomerId"
Type="Int32" />
> > > > > > > >
</SelectParameters>
> > > > > > > >
<UpdateParameters>
> > > > > > > > <asp:Parameter
Name="appointmentDa te" />
> > > > > > > >
</UpdateParameters>
> > > > > > > >
</asp:SqlDataSource >
> > > > > > > >
> > > > > > > > --- In
> > > > > > 
AspNetAnyQuestionIs Okyahoogroups. com<AspNetAnyQuestionI
sOk%
40yahoogroups. com>
> > <AspNetAnyQuestionI sOk%
> > 40yahoogroups. com>
> > > > <AspNetAnyQuestionI sOk%
> > > > 40yahoogroups. com>
> > > > > > <AspNetAnyQuestionI sOk%
> > > > > > 40yahoogroups. com>,
> > > > > >
> > > > > > > > "Dean
Fiala"
> > > > > > > > <dfiala>
wrote:
> > > > > > > > >
> > > > > > > > > Remember the
date string is just a display version 
of a
> > > > DateTime
> > > > > > > > value. Once
> > > > > > > > > you get into a
DateTime structure you can display 
it any
> > > > way you
> > > > > > > > want.
> > > > > > > > >
> > > > > > > > > You can use the
Parse method
> > > > > > > > > http://msdn2. microsoft. com/en-
> > > > > > us/library/system. datetime.
parse.aspx,
> > > > > > > > >
> > > > > > > > > to load the
structure. The simplest overload of the
> > method
> > > > uses
> > > > > > he
> > > > > > > > current
> > > > > > > > > culture of the
application to parse the string. If 
you
> > want
> > > > to
> > > > > > use
> > > > > > > > a
> > > > > > > > > different
culture or date style you need to use one 
of
> > the
> > > > other
> > > > > > > > > constructors
and supply the culture and/or style to 
use.
> > > > > > > > >
> > > > > > > > > and here's some
more on parsing....
> > > > > > > > > http://msdn2. microsoft. com/en-
us/library/2h3syy57 .aspx
> > > > > > > > >
> > > > > > > > > Once you've
created the DateTime structure, you can
> > display
> > > > the
> > > > > > > > value using
> > > > > > > > > it's ToString()
method
> > > > > > > > >
> > > > > > > > > DateTime
EnteredDate = DateTime.Parse
(EnteredString) ;
> > > > > > > > > string
FormattedDate = EnteredDate. ToString( "MM-dd-
> > > > > > yyyy"); //case
> > > > > > > > matters,
> > > > > > > > > mm is minutes
> > > > > > > > >
> > > > > > > > > On 1/28/07,
OwaiZ <owaiz_vaiyani > wrote:
> > > > > > > > > >
> > > > > > > > > > hi
> > > > > > > > > > any know
how to convert entered date string from 
dd-
> > mm-
> > > > yyyy
> > > > > > to mm-
> > > > > > > > dd-
> > > > > > > > > > yyyy when
using update in gridview
> > > > > > > > > > thanks
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Dean Fiala
> > > > > > > > > Very Practical
Software, Inc
> > > > > > > > > Now with
Blogging...
> > > > > > > > > http://www.vpsw. com/blogbaby
> > > > > > > > > Microsoft MVP
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > [Non-text
portions of this message have been 
removed]
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Dean Fiala
> > > > > > > Very Practical Software,
Inc
> > > > > > > Now with Blogging...
> > > > > > > http://www.vpsw. com/blogbaby
> > > > > > > Microsoft MVP
> > > > > > >
> > > > > > >
> > > > > > > [Non-text portions of
this message have been removed]
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Dean Fiala
> > > > > Very Practical Software, Inc
> > > > > Now with Blogging...
> > > > > http://www.vpsw. com/blogbaby
> > > > > Microsoft MVP
> > > > >
> > > > >
> > > > > [Non-text portions of this message
have been removed]
> > > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Dean Fiala
> > > Very Practical Software, Inc
> > > Now with Blogging...
> > > http://www.vpsw. com/blogbaby
> > > Microsoft MVP
> > >
> > >
> > > [Non-text portions of this message have been
removed]
> > >
> >
> > 
> >
> 
> 
> 
> -- 
> Dean Fiala
> Very Practical Software, Inc
> Now with Blogging...
> http://www.vpsw.
com/blogbaby
> Microsoft MVP
> 
> 
> [Non-text portions of this message have been removed]
>




[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/join

    (Yahoo! ID required)

<*> To change settings via email:
    mailto:AspNetAnyQuestionIsOk-digest@yahoogroups.com 
   
mailto:AspNetAnyQuestionIsOk-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )