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

  • SEARCH
  • Home
  • 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 7603395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:38:43+00:00 2026-05-30T23:38:43+00:00

I have an Editable Data grid which is pulling data from a SQL query

  • 0

I have an Editable Data grid which is pulling data from a SQL query one of the field has a Y or N answer and therefore needs to be a checkbox however in Edit Mode it shows as a field and errors if I put this in

<asp:CheckBox ID="ALFSUPR" runat="server" Checked='<%# Bind("pric_c_alfsupreq") %>'></asp:CheckBox>

Is there a simple way of converting the Text Field to a CheckBox which when Checked has a value = Y

Thanks

  • 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-05-30T23:38:45+00:00Added an answer on May 30, 2026 at 11:38 pm

    Try something like this:

    Checked='<%# Eval("pric_c_alfsupreq").ToString().Equals("Y") %>'>
    

    UPDATE:

    Since you’re using an old DataGrid (you should be using DataGridView nowadays), you should have something similar to this in your DataGrid definition:

    <asp:DataGrid ID="Grid" runat="server" PageSize="5" AllowPaging="True"
                  DataKeyField="EmpId" AutoGenerateColumns="False" CellPadding="4"
                  ForeColor="#333333" GridLines="No" 
                  OnPageIndexChanged="Grid_PageIndexChanged"
                  OnCancelCommand="Grid_CancelCommand" 
                  OnDeleteCommand="Grid_DeleteCommand"
                  OnEditCommand="Grid_EditCommand"
                  OnUpdateCommand="Grid_UpdateCommand">
    

    See the OnUpdateCommand…

    Now the method that should run when you’re applying an update to the row’s data:

    protected void Grid_UpdateCommand(object source, DataGridCommandEventArgs e)
    {
        con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);
    
        char value = "N"
    
        // You'll have to change the index here to point to the CheckBox you have in
        // your DataGrid.
        // It can be on index 1 Controls[1] or 2 Controls[2]. Only you know this info.
        if(((CheckBox)e.Item.Cells[0].Controls[0]).Checked == true)
        {
             value = "Y";;
        }
    
        cmd.Parameters.Add("@pric_c_alfsupreq", SqlDbType.Char).Value = value;
    
        cmd.CommandText = "Update command HERE";
    
        cmd.Connection = con;
    
        cmd.Connection.Open();
    
        cmd.ExecuteNonQuery();
    
        cmd.Connection.Close();
    
        Grid.EditItemIndex = -1;
    }
    

    Hope you get the idea. If you need this code in any other moment you can place it in the OnEditCommand, OnDeleteCommand, etc…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to populate an Advanced Data Grid which have the following fields: Continent->State->Society-->Actual
Context: I have a data grid where the following has been implemented. tabbing through
I am using jqgrid 3.8. I have a grid which is having some editable
I have a data grid view ( say 5 columns ) . User has
I have an EditorGrid in which I'm binding data using XML. One of the
I have editable grid view, If I click on edit in any row say
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have a simple table view which is editable. All I need the user
I have a listview with lists lines of an invoice (Which are editable), each
I have this datagrid which has columns with a NumericStepper as an itemEditor where

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.