event sequence

G

Guest

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 );
}
 
G

Guest

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);
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top