Solved

How to bind the check box in Grid View.How to show it as Checked or Unchecked

Posted on 2013-01-09
6
573 Views
Last Modified: 2013-01-14
Hi,
I have a bit field in the SQL Table.I am binding that field to check box control in Grid View.
If the SQL Table value equal to 1 I want to show the Check Box checked,otherwise
I want to unchecked it.

Now after binding the Data Table to Grid View it is showing True or False besides Check Box.Check Box is Just empty.I don't want to show any Text besides check box.Just want to show it as checked or unchecked.

Any suggestions please.

Thanks

Thanks
0
Comment
Question by:KavyaVS
  • 2
  • 2
  • 2
6 Comments
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 100 total points
ID: 38761718
check this

<asp:TemplateField HeaderText="SU">
  <ItemTemplate>
      <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%#Bind("su") %>' Enabled="false" />
    </ItemTemplate>
</asp:TemplateField>


refer this link for more details
http://forums.asp.net/t/1193113.aspx
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 100 total points
ID: 38761719
0
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 400 total points
ID: 38762208
Check this
http://stackoverflow.com/questions/6445178/set-checkbox-in-gridview-based-on-datatable-value

<asp:TemplateField HeaderText="Complete">
<ItemTemplate>
    <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# bool.Parse(Eval("PROCESSED").ToString()) %>' Enable='<%# !bool.Parse(Eval("PROCESSED").ToString()) %>'/>
</ItemTemplate>

Open in new window

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:KavyaVS
ID: 38762627
Thanks it's working.
Can I add the check box column to Grid View in the code behind.Now I am adding the ButtonField and Bound Columns from the code behine.
This is the button field.
ButtonField btn = new ButtonField();
            btn.ButtonType = ButtonType.Link;
            btn.DataTextField = "Date";
            btn.SortExpression = "Date";
            btn.ShowHeader = true;
            btn.HeaderText = "Date";
            grd1.Columns.Add(btn);

Thanks.
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 400 total points
ID: 38766484
0
 

Author Closing Comment

by:KavyaVS
ID: 38774796
Thanks
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question