Grid View Event Not Working on Alternating Rows

Grid View Event Not Working on Alternating Rows

am 28.12.2005 04:15:43 von Stuart Shay

Hello All:

I am working on a ASP.NET GridView, I am not sure to correctly define the
condition so Alternating Rows are fired with in the event. My Code only
works on Item Rows in both Normal and Edit State.

protected void gvUserList_RowDataBound(object sender, GridViewRowEventArgs
e)
{

if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState ==
DataControlRowState.Normal)
{
}

if( e.Row.RowState == DataControlRowState.Edit)
{
}

}

Thanks
Stuart

Re: Grid View Event Not Working on Alternating Rows

am 29.12.2005 07:00:56 von Stuart Shay

I solved the problem would have been nice if MSFT provided this sample in
the documentation for binding a control (dropdown,checklist,etc) in a Edit
Mode for the GridView

if ((e.Row.RowState == (DataControlRowState.Edit |
DataControlRowState.Alternate)) || (e.Row.RowState ==
DataControlRowState.Edit))
{
/* Edit Mode Code Here (DataControlRowState.Edit) */
}
else if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState ==
DataControlRowState.Normal || e.Row.RowState ==
DataControlRowState.Alternate))
{
/* DataRow Mode Code Here (DataControlRowState.Normal) */
}




"Stuart Shay" wrote in message
news:OdEC$z1CGHA.4000@TK2MSFTNGP10.phx.gbl...
> Hello All:
>
> I am working on a ASP.NET GridView, I am not sure to correctly define the
> condition so Alternating Rows are fired with in the event. My Code only
> works on Item Rows in both Normal and Edit State.
>
> protected void gvUserList_RowDataBound(object sender, GridViewRowEventArgs
> e)
> {
>
> if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState ==
> DataControlRowState.Normal)
> {
> }
>
> if( e.Row.RowState == DataControlRowState.Edit)
> {
> }
>
> }
>
> Thanks
> Stuart
>
>

RE: Grid View Event Not Working on Alternating Rows

am 09.01.2008 00:10:16 von Robert Faulkner

Hi.

All I can say is thank you and I totally agree. I have searched the web for examples of how to achive this, but yours is the ownly article I have found.

Many thanks.

Neil.

From http://www.developmentnow.com/g/8_2005_12_0_0_657364/Grid-Vi ew-Event-Not-Working-on-Alternating-Rows.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com