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

Top 5 Contributors of the Month
Post New Web Links

How to Use checkbox column in SPGridView programatically

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :SharePoint




I am developing a webpart which displays a SPGridView. I need to have a checkbox in one column in each row of SPGridView. Can anybody know how to do it programatically.



View Complete Post

More Related Resource Links

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??

Change Default Column Value programatically

On a Document Library Settings Page, there is a new setting in SP2010: "Change Default Column Value". Changing the default value of the Field is different from this value. Does anyone know what this value is and where to set it programatically? Also, what libraries is this setting available on? This code updates the field's default value but not the property mentioned above: SPField field = list.Fields["Column"]; field.DefaultValue = "DefaultValue"; field.Update(); Thanks!

WPF Datagrid with multiple row selection/checkbox column template

Hello, I am using the WPF Toolkit Datagrid with a checkbox defined in a template column/template cell. We are using the checkbox template so that selecting the checkbox will also highlight the row in the datagrid. Here is the template definition: <dg:DataGridTemplateColumn MinWidth="50" Width="Auto" Header="" CanUserReorder="False"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding Path=IsCheckedm, Mode=TwoWay}" /> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> We are allowing multiple row selection in the datagrid and using MVVM (using MVVM Light). We would like to keep a list in the View Model of selected rows as they are selected/unselected. Any suggestions on how we can leverage MVVM to keep the list of selected/unselected elements current. Many Thanks --Sam

Unable to Bind a CheckBox to an Oracle column

The code below works great in SQL Server with a BIT column.  How do you get it to work in Oracle?  I've tried number(1), char(1)...etc but nothing works!  Using Eval is no good becuse that breaks the Update. <asp:CheckBox ID="cbxStatus" runat="server" Checked='<%# Bind("status") %>' /> Always get this error: System.InvalidCastException: "Specified cast is not valid".  Anyone know the trick to making this work with Bind? 

Checkbox column not selectable

Hello all, I added a checkbox column and wrote the following code to handle it but checkboxes are not selectable. Any ideas? Private Sub chkBoxAll_Approve(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkButton.Click Dim ctr As New DataGridViewRow Try For Each ctr In dgvRequests.SelectedRows If chkBoxColumn.Selected = True Then Exit For ElseIf dgvRequests.CurrentRow.Cells("requestType").Value = "OOORequest" Then Call updateOutOfOffice(LeaveStatus.Approved) Else Call updateRequest(LeaveStatus.Approved) End If Next Catch ex As System.Exception MessageBox.Show(ex.Message) End Try End Sub  

Trying to apply style to a gridview column programatically..


I have a grid view that is bound from my code behind.   If the text of a label is equal to the value of a querystring, I want to apply a specific class/style that is in my .css.  I've tried this, but doesn't seem to have any affect...  How can I set the class for a column in the gridview if the two values match?   

 protected void gvMenu_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            Label lblSubSectionIDForComparing = e.Row.FindControl("lblSubSectionID") as Label;
            Label lblSubSectionNameForComparing = e.Row.FindControl("lblSubSectionName") as Label;

            if (lblSubSectionIDForComparing != null)
                if (lblSubSectionIDForComparing.Text == Request.QueryString["SubSectionID"])
                    e.Row.Cells[2].CssClass = "SubSectionNav";  <-- This is what I thought would work...


How to create a BCS (Business Conectivity Services) column programatically?



I have a SP2007 app that adds a BDC column to a list like this:

  string xml = "<Field Type=\"BusinessData\" DisplayName=\"Product\" ...>"; 
  SPField fld = list.fields.AddFieldAsXml(xml, true, addOptions);

  BusinessDataField bdcField = fld as BusinessDataField;
  bdcField.SystemInstanceName = instance;
  bdcField.EntityName =         entity;
  bdcField.BdcFieldName =       bdcFldName;
  bdcField.Profile =            profile;
  bdcField.HasActions =         hasActions;


How do I do it in SP 2010? Class BusinessDataField  does not exist in Microsoft.SharePoint.Portal.WebControls,
and I found no samples.

Thanks in advance


rendering a CheckBox web control from Oracle NVARCHAR2 (1) data column


I have a data column in Oracle as NULLABLE NVARCHAR2 (1) which accepts Y for True or N for False and nulls. 

When I have Dynamic Data to render this column, it renders it as a TextBox web control.

Is there a way to make Dynamic Data to render it as a CheckBox web control?


how to bind a nullable column to a checkbox



I'm trying to bind a nullable column to a checkbox:

<asp:CheckBox ID="SubjectIsSchoolTruantCheckBox" runat="server" Checked='<%# CheckNull(Eval("SubjectIsSchoolTruant")) %>'  />



        protected Boolean CheckNull(Object sItem)
            if (sItem == null)
                return false;

            int i = (int)sItem;

            if (i > 0)
                return true;
                return false;


The value SubjectIsSchoolTruantCheckBox can be null.

I am running into the following error when I try to update:  Failed to set one or more properties on type GRIPS.ActivityMember.   is no

Adding checkbox column to data


I need to add a checkbox column to my data and do it programmatically.  I've seen a lot of other posts that address this, but can't get it to work in VB.

        Dim all3 = From p In all2
                 Let tempCost = db.maximum((p.PosVal - DollarBase) * slope + 1, 1)
                 Let Cost = String.Format("{0:$.}", Convert.ToDouble(tempCost))
                 Select p.Player, p.Team, Cost

        GridView1.DataSource = all3

        'Need to add checkbox code here


Programatically adding the "SummaryLinks" type column to the Site columns list



Can anyone help me with the sample code to programatically add the "SummaryLinks" type column to the Site columns list.



AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Tooltip for GridView Column Headers (ASP.Net)

I just wanted to add auto tooltips for my GridView headers. There are couple of ways but I don't want to use javascript and wanted to use simple 'title' attribute. It took couple of hours to get the working code supporting sortable columns. I thought it will be very useful for others. Here's the code and logic behind it.

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code
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