Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8814925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:14:59+00:00 2026-06-14T04:14:59+00:00

I have a problem and I can’t find an answer to it. In VS2012

  • 0

I have a problem and I can’t find an answer to it.
In VS2012 I created an ASP.NET website in C#.

I have my membership provider setup and working, now I wanted to make an adminpage where an admin could edit the role and block a user. From the server explorer, I dragged the asp_membership table to the page and it created itself.

I’ve deleted a few irrelevant columns and added an itemtemplatefield with two buttons. Take a look at the code first:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="UserId" DataSourceID="SqlDataSource1" 
    EmptyDataText="There are no data records to display." 
    OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >
    <Columns>
        <asp:CommandField ShowDeleteButton="True" />
        <asp:TemplateField HeaderText="Block users">
            <ItemTemplate>
                <asp:Button runat="server" ID="btnBlock" CommandName="Block"
                    Text="Block" OnClick="btnBlock_Click" Visible='<%# Convert.ToBoolean(Eval("IsLockedOut").ToString()) %>'/>
                <asp:Button runat="server" ID="btnDeblock" CommandName="Deblock"
                    Text="Deblock" OnClick="bntDeblock_Click" Visible='<%# Convert.ToBoolean(Eval("IsLockedOut").ToString()) %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="UserId" HeaderText="User id" ReadOnly="True" 
            SortExpression="UserId" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
        <asp:CheckBoxField DataField="IsApproved" HeaderText="Confirmed" 
            SortExpression="IsApproved" />
        <asp:BoundField DataField="CreateDate" HeaderText="Created" 
            SortExpression="CreateDate" />
        <asp:BoundField DataField="LastLoginDate" HeaderText="Last login" 
            SortExpression="LastLoginDate" />
        <asp:CheckBoxField DataField="IsLockedOut" HeaderText="Locked" 
            SortExpression="IsLockedOut" />
        <asp:BoundField DataField="LastLockoutDate" HeaderText="Last lockout" 
            SortExpression="LastLockoutDate" />
        <asp:BoundField DataField="FailedPasswordAttemptCount" 
            HeaderText="Failed logins" 
            SortExpression="FailedPasswordAttemptCount" />
        <asp:BoundField DataField="Comment" HeaderText="Comments" 
            SortExpression="Comment" />
    </Columns>
</asp:GridView>

I’m trying to make two butons (block and deblock) that should be visible if the checkboxfield “IsLockedOut” is disabled and invisible if… you get the point.

The buttons both disappear when I load the page. I assume the error resides here: <%# Convert.ToBoolean(Eval(“IsLockedOut”).ToString()) %>?
Can someone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:15:00+00:00Added an answer on June 14, 2026 at 4:15 am

    You shouldn’t need the .ToString() or the Convert.ToBoolean(); .NET will pretty much do that under the hood for you.

    Visible='<%# Eval("IsLockedOut") %>'
    

    What do you see if you add a <asp:Label /> to your ItemTemplate and bind the Text property as the above? Is your IsLockedOut property a Nullable<Boolean>? If it is, you could try this:

    Visible = '<%# Eval("IsLockedOut") ?? true %>'
    

    Or

    Visible = '<%# ((Nullable<bool>)Eval("IsLockedOut")).GetValueOrDefault(true) %>'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem and can't find a solution. I am making an accordion
I have a problem which i can't seem to find the solution to. I
I'm currently working with django generic views and I have a problem I can't
I'm building a multi-tenant app with ASP.NET MVC and have a problem with validating
I have a problem i can't find the wrong in this function it sometimes
I have a problem and can't find information. I run my web-app from jsp-page
I have a problem i can't solve by myself and which I coudn't find
I seem to have a problem and can't get it work. I'm working on
I have another problem I can't seem to solve..., or find on this site...
I have a problem I can't find out myself so any help appreciated. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.