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