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 8156495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:58:13+00:00 2026-06-06T16:58:13+00:00

In my grid view I’ve a checkbox column, and am binding the gridview with

  • 0

In my grid view I’ve a checkbox column, and am binding the gridview with a dictionary. I need to get the corresponding Id from the checked boxes.

In my dictionary I’ve the key values like

Id         Name
--         ----
 1         Arts
 2         Science
 3         Engineering

Here, I tried to bind the value for this checkbox as

<asp:TemplateField>
    <ItemTemplate>
      <asp:CheckBox ID="chkSelItem" value="<%# Eval("Key.Id") %>" 
                                                       runat="server" />
    </ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Department">
    <ItemTemplate>
         <%# Eval("Key.Name") %>
    </ItemTemplate>
    <HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>

and from the codebehind, I tried like

foreach (GridViewRow row in gridDepartments.Rows)
        {
            CheckBox chkSelItem = (CheckBox)row.FindControl("chkSelItem");

            if (chkSelItem.Checked)
            {
                int departmentId = int.Parse(chkSelItem.Text);
                ////
                ////                 
            }
        }

its throwing error, or not showing any value for the checkbox.

I also trid with FindControl, but no use of it, coz in the key & Value pair am using a class(which inherits another class) and a bool. thats what am trying like this, can anyone help me here, thanks in advance…..

  • 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-06T16:58:15+00:00Added an answer on June 6, 2026 at 4:58 pm
    You can try this one...
    
    Bind id to lable instead of to checkbox as below.
    
    <asp:TemplateField>     
    <ItemTemplate>       
    <asp:CheckBox ID="chkSelItem" runat="server" />     
    
    <asp:Label ID="lblSelectedItem" value=<%# Eval("Key.Id")) %> visible="False"/>
    </ItemTemplate> </asp:TemplateField>
    
    
    
    In codebehind try this
    
    foreach (GridViewRow row in gridDepartments.Rows)         
    {             
          CheckBox chkSelItem = (CheckBox)row.FindControl("chkSelItem");
           Label lblSelectedItem= (Label)row.FindControl("lblSelectedItem");
    
          if (chkSelItem.Checked) 
          {
                     int departmentId = int.Parse(lblSelectedItem.Text); 
          }
    } 
    
    
    
    Hope this is what u want...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to bind grid view with check box column, droupdown column and text
I have a parent grid view (UserTransactionGridView) which i'm binding with the output from
I have a data grid view with checkbox column as the 1st column. What
how to detect grid view empty cell ? I need it for highlighting. So
I have a grid view with multiple select check boxes. I want to return
In my grid view there is column which contain with string data type. Some
I have a grid view which contains some sequence numbers. Each column needs to
I need to center grid view horizontally in my android layout.xml. I have searched
I have a grid view which I am binding with data table. My problem
I have a grid view that lists contents of a table, table has column

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.