Solved

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

Posted on 2013-01-09
6
574 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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