Solved

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

Posted on 2013-01-09
6
566 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to error 4 46
DateTimepicker 4 33
designing in object programming 12 42
ASP.net VB.net Highlight html text in yellow in body of email 5 10
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now