Solved

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

Posted on 2013-01-09
6
564 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

24 Experts available now in Live!

Get 1:1 Help Now