calling GridView1.DataBind() in th event handlers.
"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:yKcE1AVCHHA.4372@TK2MSFTNGXA01.phx.gbl...
> Hello dev648237923,
>
> From your description, you're gettnig some strange behavior(need two time
> to make Gridview change status) when using GridView to display and edit
> data from database, correct?
>
> As for the GridView databinding, are you using an associated DataSource
> control(SqlDataSource or ObjectDataSource) or manually set the DataSource
> property and call DataBind method ?
>
> For Gridview, if you're using associated DataSource control to populate
> data, it will automatically handle the selecting, editing and updating
> events. However, if you manually bind the data, you need to manually hook
> those events (like RowEditing, RowUpdating, RowCancelingEdit ...) in code.
> Also, in each of such event, since you manually bind data to the GridView,
> you also need to do the databinding in each of those event because after
> each of such event, GridView need to repopulate the Rows collection. e.g.
>
> ========================
> ....................
> protected void GridView1_RowEditing(object sender, GridViewEditEventArgs
> e)
> {
> GridView1.EditIndex = e.NewEditIndex;
> GridView1.DataSource =
> SqlDataSource1.Select(DataSourceSelectArguments.Empty);
> GridView1.DataBind();
> }
>
> protected void GridView1_RowCancelingEdit(object sender,
> GridViewCancelEditEventArgs e)
> {
> GridView1.EditIndex = -1;
>
> GridView1.DataSource =
> SqlDataSource1.Select(DataSourceSelectArguments.Empty);
> GridView1.DataBind();
> }
>
> ..............
> ===========================
>
> If you feel necessary I can send you a test page for reference. Please
> feel
> free to let me know if you have any further questions or any thing
> particular in your scenario.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx. >
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>