Re: GridView SelectedIndexChanged question

Discussion in 'ASP .Net' started by Alexey Smirnov, Oct 24, 2009.

  1. On Oct 24, 3:12 pm, Alexey Smirnov <> wrote:
    > On Oct 24, 2:59 pm, "David C" <> wrote:
    >
    >
    >
    >
    >
    > > I have a GridView that I want to show or hide LinkButtons that exist outside
    > > of the GridView based on a data column in the GridView when that row is
    > > selected.  I have the code below for the SelectedIndexChanged event but it
    > > always falls through to the False condition.  The data column named
    > > VoidCheck is a SQL Server bit data type.  Can someone help me spot the
    > > problem?  Thanks in advance.

    >
    > > David

    >
    > >     Protected Sub gvVendorChecks_SelectedIndexChanged(ByVal sender As
    > > Object, ByVal e As System.EventArgs) Handles
    > > gvVendorChecks.SelectedIndexChanged
    > >         ' Get the currently selected row using the SelectedRow property.
    > >         Dim row As GridViewRow = gvVendorChecks.SelectedRow

    >
    > >         If row.RowState = DataControlRowState.Selected Then
    > >             Dim bolvoid As Boolean =
    > > Convert.ToBoolean(DataBinder.Eval(row.DataItem, "VoidCheck"))
    > >             If bolvoid = True Then
    > >                 ' voided check selected so show the remove void button
    > >                 LBtnRemoveVoid.Visible = True
    > >                 LBtnVoidCheck.Visible = False
    > >             Else
    > >                 LBtnRemoveVoid.Visible = False
    > >                 LBtnVoidCheck.Visible = True
    > >             End If
    > >         End If
    > >     End Sub

    >
    > The RowType property is a bitwise combination of the values and not a
    > boolean. Either remove
    >
    > ** If row.RowState = DataControlRowState.Selected Then **
    >
    > because it makes no sense, or replace it by
    >
    > ** If (row.RowState And DataControlRowState.Edit) > 0 Then **
    >
    > Hope this helps.- Hide quoted text -
    >
    > - Show quoted text -


    P.S.

    Please see more at http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrow.rowstate.aspx
    Alexey Smirnov, Oct 24, 2009
    #1
    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. =?Utf-8?B?QVQ=?=
    Replies:
    1
    Views:
    4,438
    =?Utf-8?B?QVQ=?=
    Apr 1, 2005
  2. sck10
    Replies:
    1
    Views:
    7,281
    Steven Cheng[MSFT]
    Apr 3, 2006
  3. =?Utf-8?B?LU1U?=

    Raising SelectedIndexChanged event in a gridview

    =?Utf-8?B?LU1U?=, Jun 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    16,335
    =?Utf-8?B?SmF5?=
    Jun 6, 2006
  4. graphicsxp
    Replies:
    0
    Views:
    461
    graphicsxp
    Jul 11, 2006
  5. David C
    Replies:
    11
    Views:
    3,371
    Alexey Smirnov
    Oct 26, 2009
Loading...

Share This Page