.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

databound checkbox default check not working

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :ASP.Net

Hi I have a datagrid which is bound to a stored procedure in the code behind. This works fine. But the datagrid contains a checkbox which I need to be default checked. First I didn't bind the checkbox and just used:

<ItemTemplate>         <asp:CheckBox ID="chkSelection" Runat="server" Checked= "true" />       </ItemTemplate>

but they show as unchecked. then bound it using:

        <asp:CheckBox ID="chkSelection" Runat="server" Checked= '<%# Bind("chkSelection") %>' />

  <ItemTemplate>         <asp:CheckBox ID="chkSelection" Runat="server" Checked= '<%# Bind("chkSelection") %>' />    &nb

View Complete Post

More Related Resource Links

Disable check box in a gridview does not working



I have a check box in a template field in a gridview.

Based on some condition, I want those check boxs to  be enable and disable.

I am trying the below code but does working..

 protected void GVstudents_RowDataBound(object sender, GridViewRowEventArgs e)
              if (e.Row.RowType == DataControlRowType.DataRow)
                    string studentID = GVstudents.DataKeys[0].Value.ToString();
                    int stdID = Convert.ToInt32(studentID);
                    int schID = profile.getSchoolIDByStudentID(stdID);
                    int tchrID = profile.getTeacherIDByStudentID(stdID);

                    if (patti.chkIsTeacherPaid(stdID, schID, tchrID))
                        CheckBox cb = (CheckBox)e.Row.FindControl("chkTeacherPayment");
                        cb.Enabled = false;
                        cb.Checked = true;


any help??

Gridview check all not working in Mozila Firefox


hi all,

i has an gridview first column header is Checkbox, when i click on that all the detail column checkboxes were selected if i use IE but the same not working in Mozila Firefox

below is my code

function checkAll()
                  var totalChkBoxes = parseInt('<%= gv5.Rows.Count %>');
                  var gvControl = document.getElementById('<%= gv5.ClientID %>');
                  var gvChkBoxControl = "cbCheckProd";
                  var mainChkBox = document.getElementById("chkBoxAll");
                  var inputTypes = gvControl.getElementsByTagName("input");
                  for (var i = 0; i < inputTypes.length; i++)

"Access is denied. Check that the Default Content Access Account has access to this content"


Our search is not working. The crawl log indicates following error: "Access is denied. Check that the Default Content Access Account has access to this content, or add a crawl rule to crawl this content. (The item was deleted because it was either not found or the crawler was denied access to it.)".


If I check the event viewer, it indicates following error: "Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. [CLIENT: <local machine>]"


My default content access account is another one than this NT AUTHORITY\NETWORK SERVICE account. The content access account password is correct. Apparently this content access account is translated to the NETWORK SERVICE account upon a crawl. And this network service account doesn't has the appropriate rights on database level. How can I fix this?


wpf datagridview checkbox column selection not working fine.

Hi Experts,in my c#.net windows based wpf application i added  a datagridview.dynamically i added checkboxcolumn to that datagridview DataGridViewCheckBoxColumn cbCol = new DataGridViewCheckBoxColumn(); GridSource.Columns.Add(cbCol); and another column is string. to this column am hardcoding the values DataTable _datatable = new DataTable(); _datatable.Columns.Add("Name", typeof(string)); _datatable.Rows.Add("CSRs"); _datatable.Rows.Add("Customers"); GridSource.DataSource = _datatable; till here fine am getting two columns (checkbox and Name)when i am trying to check those checkboxes problem comming.am trying to get the count of the checked rows for that i used below code int cbcount = 0; foreach (DataGridViewRow _dgRow in GridSource.Rows) { if ((bool)_dgRow.Cells[0].Value) cbcount++; } cbcount will give the checked count.but the problem raising here if i check 2 rows it giving 1if i check 5 rows it giving 4if i check 1 row it giving me 0means am getting n-1 resultwhere i did wrong??

Styling a checkbox so the check goes outside the box

Hi all.  I'm trying to style a checkbox so that the custom check mark goes outside the border.  I normally would make this work by setting a negative margin, but the border of the checkbox constrains the contents, so that only the bit drawn inside is visible ?  This is what I have:       <Style x:Key="{x:Type CheckBox}" TargetType="CheckBox">     <Setter Property="SnapsToDevicePixels" Value="true"/>     <Setter Property="OverridesDefaultStyle" Value="true"/>     <Setter Property="Template">     <Setter.Value>     <ControlTemplate TargetType="CheckBox">     <BulletDecorator Background="Transparent">     <BulletDecorator.Bullet>     <Border x:Name="Border"   Width="13"   Height="13"   Margin="-3,-3,3,3"   CornerRadius="0"   Background="Transparent"   BorderThickness="1"   BorderBrush="Black">     <Path   Width="16" Height="16"   Margin="3,-3,0,0"   x:Name="CheckMark"   SnapsToDev

Html.CheckBoxFor - how can I make checkbox default checked ?

I have:Html.CheckBoxFor(model => model.available) how can I have checkbox default checked ?

Check In / Check Out not working properly

At various points during the day, I check back in the master and CSS files I've been working on.  However, it doesn't show them as checked in ... they are still flagged with green check in SP Designer.   And what is more confusing, sometimes I can't save anything because it says that it is checked out.  But I'm the one who checked it out.  And it thinks it is checked in.  So I try to check it out again, and it won't let me check it out. The only way I got around this yesterday was to rename the master file.  Then rename it back to it's original name. Suggestions?

Datagrid checkbox check uncheck in single click

Hi, I have a datagrid colums of checkbox type. Users have to click twice on the checkbox to check or uncheck. Is there a way to do this in one click. Thanks Vijay

checkbox in listview layout template check select all checkboxes in listview itemtemplate

hi,how to do this when the checkbox in listview layout template check select all checkboxes in  listview itemtemplate.I dont give 'Eval 'field to checkbox present in itemtemplate.pls reply me.Many thanks in advance.

gridview checkbox sorting not working

Hi All,I have a grid view which populates data just for viewing purpose(report) . One field shows the Active/inactive status for which I am showing a checkbox..if data in database is 1 then the checkbox will be checked otherwise it'll not be checked. This field is inactive so that the User does not check/uncheck it. The issue is that this field cannot be sorted. All the fields in the gridview are being sorted. Below is the code for the checkbox column. <asp:TemplateField HeaderText="InActive" SortExpression="Inactive"><HeaderTemplate ><asp:Label ID="lblStat" CssClass="copyLabel" Text="Inactive" CommandArgument="Inactive"                    runat="server"></asp:Label></HeaderTemplate> <ItemTemplate><asp:CheckBox runat="server" ID="chkStatus" Enabled="false"/></ItemTemplate></asp:TemplateField>I have given AllowSorting="True" in the gridview properties. The code in the gridview sorting event works fine for all other columns except the checkbox column. Please help and suggest some scenarios/links so that I can achieve sorting for the checkbox column also.Thanks in advance.

axWebBrowser check checkbox




is it possible to force axWebBrowser to check checkbox? I have no idea how to do it.

Thank you for your advices.

Getting a Checkbox in a datagrid to check before RowDetails expand the row.



I am having trouble getting a checkbox in my datagrid to check in certain situations. The row details in my grid cause the row to expand when the row is selected. When no row is selected, or a row below the row just clicked was the selected row prior to the click, things work fine (the checkbox I clicked on gets toggled and the row expands to show its rowdetails). If a row above the row I am clicking was selected (and therefore expanded, showing its rowdetails) when that row collapses, my current row moves up (because the row above collapsed) and the current row expands. However, the checkbox in that row (in the column that I clicked on) does not get checked in this case. I suspect it's because it is no longer in the space where the click occurred (because it works if clicking this checkbox/row doesn't cause it to move up before expanding). Is there a way to get the checkbox click to happen before the row selection? I seem to recall properties on controls in the past that indicated whether they answered before or after their child controls (maybe that was forms) but I cannot find any such property to set on the WPF DataGrid. Any suggestions? Thanks.


Default Content Approval Workflow not firing after Check-In from Office 2007


I have created an Approval Workflow for a Document Library and assigned it as the Default Content Approval Workflow (in the UI: Start this workflow to approve publishing a major version of an item).

If, through the SharePoint web interface, I "Check-In" and select a Major Version (e.g. 1.0) or I "Publish a Major Version", this workflow is initiated as one would expect.

However, if through Microsoft Office 2007 (e.g. Word) I Check-In the document as a Major Version (e.g. 1.0) it does NOT initiate the workflow. It DOES set the Document Status to Pending but does NOT initiate the Approval workflow. It then becomes necessary to "Cancel [the] Approval" in the GUI and re-Publish it in order for the workflow to be initiated. This is crazy! Microsoft have achieved fantastic results with their Office integration, why hasn't the initiation of the Default Content Approval Workflow been included?

Can anybody replicate this? What is the correct channel for reporting this to Microsoft? Has anybody else discovered this and found a solution?

I can't believe SharePoint has been used as a Document Management System and nobody else has discovered this flaw?

check all not working in mozila


hi all, i desinged a gridivew, there first column will be a Checkbox, if the user clicks on the header of the Checkbox then all the child should be select/deselect, its working fine in IE but, in Mozila Firefox its not working.  below is my code


                                  <asp:TemplateField ItemStyle-Width="2%">
                                          <asp:CheckBox ID="cbCheckProd" runat="server" oncheckedchanged="cbCheckProd_CheckedChanged" />

Custom checkbox control 'checked' property is not working .


Hello ,


Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.



public class TngCheckBox : CompositeControl


i have written the required properties which are working fine except the "checked" property. he

checkbox issue before selecting any check box i need to check is this already enable fasle


Hi i have some checkbox in my asp.net page.. i have CheckBox4,CheckBox5,CheckBox6 up to CheckBox10

if checkbox4 not enable fasle if user select any other other checkbox cant able to check user.. i have to send message please check CheckBox4 first  how to do this...? 

SSIS job to check if SSAS cubes are working


Hi all,

I am having some management problems and need to prove that the cubes are available for browsing.

I have had a look at SSIS to see if there is a task but I suspect I need to script something out.

Can anyone give me any pointers ?

Many thanks.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend