event sequence

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFiYmxlcg==?=, Jul 17, 2006.

  1. I have a calendar control and a formview control on the same page. Based on
    wether I have data for the calendar day of the SelectionChanged event, I want
    to change the FormView to the correct mode, insert or edit. I can't figure
    out how to make this happen and am not sure when I should set the FormView
    mode and rebind it.

    Thanks for any help on this.

    protected void calRideCounts_selectionChanged( object sender, EventArgs e ) {
    FillRideCountsDataset();
    bool found = false;
    if ( dsRideCounts != null && dsRideCounts.Tables.Count > 0 ) {
    foreach ( DataRow dr in dsRideCounts.Tables[0].Rows ) {
    DateTime rideDate = (DateTime)dr["RideDate"];
    if ( rideDate == calRideCounts.SelectedDate ) {
    // need to set FormView from insert to edit mode
    found = true;
    }
    }
    }
    DateTime dt = calRideCounts.SelectedDate;
    if ( found ) {
    fvRideCounts.DefaultMode = FormViewMode.Edit;
    fvRideCounts.DataBind();
    }

    TextBox tb = (TextBox)fvRideCounts.FindControl( "tbRideDate" );
    tb.Text = String.Format( "{0:MMMM dd}", dt );
    }
     
    =?Utf-8?B?RGFiYmxlcg==?=, Jul 17, 2006
    #1
    1. Advertising

  2. Don't try to change the mode of the formview by setting the DefaultView
    property, instead use the ChangeMode method as follows:

    FormView.ChangeMode(FormViewMode.Edit);

    or

    FormView.ChangeMode(FormViewMode.Insert);

    or

    FormView.ChangeMode(FormViewMode.ReadOnly);

    "Dabbler" wrote:

    > I have a calendar control and a formview control on the same page. Based on
    > wether I have data for the calendar day of the SelectionChanged event, I want
    > to change the FormView to the correct mode, insert or edit. I can't figure
    > out how to make this happen and am not sure when I should set the FormView
    > mode and rebind it.
    >
    > Thanks for any help on this.
    >
    > protected void calRideCounts_selectionChanged( object sender, EventArgs e ) {
    > FillRideCountsDataset();
    > bool found = false;
    > if ( dsRideCounts != null && dsRideCounts.Tables.Count > 0 ) {
    > foreach ( DataRow dr in dsRideCounts.Tables[0].Rows ) {
    > DateTime rideDate = (DateTime)dr["RideDate"];
    > if ( rideDate == calRideCounts.SelectedDate ) {
    > // need to set FormView from insert to edit mode
    > found = true;
    > }
    > }
    > }
    > DateTime dt = calRideCounts.SelectedDate;
    > if ( found ) {
    > fvRideCounts.DefaultMode = FormViewMode.Edit;
    > fvRideCounts.DataBind();
    > }
    >
    > TextBox tb = (TextBox)fvRideCounts.FindControl( "tbRideDate" );
    > tb.Text = String.Format( "{0:MMMM dd}", dt );
    > }
    >
     
    =?Utf-8?B?Y2xpY2tvbg==?=, Jul 17, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guadala Harry

    PostBack Event Firing Sequence

    Guadala Harry, Aug 15, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,091
    Bredal Jensen
    Aug 15, 2004
  2. Josh

    Event Sequence Wrong

    Josh, Aug 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    425
    Eliyahu Goldin
    Aug 17, 2005
  3. =?Utf-8?B?SmF5?=
    Replies:
    3
    Views:
    975
    Kevin Spencer
    Dec 21, 2005
  4. Phillip N Rounds

    Question re Event Firing Sequence

    Phillip N Rounds, Mar 1, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    409
    Eliyahu Goldin
    Mar 5, 2006
  5. stef mientki
    Replies:
    13
    Views:
    690
    stef mientki
    Oct 20, 2007
Loading...

Share This Page