We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

checkbox in grid does not display correctly

Thread ID:

Created:

Updated:

Platform:

Replies:

74988 Jul 7,2008 04:59 PM Sep 25,2008 03:40 PM ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Mike Bourne
Asked On July 7, 2008 04:59 PM

I have a datasource that contains 3 columns. 2 of the 3 columns are text data and the 3rd is a "Bit" field that is either true or false.

I have a blank aspx (vb.net) page that I dragged a grid control onto, Set the datasource based on my sqldatasource parameters. I added a checkbox control in the 3rd column using the "Edit Template" functionality.

The text data displays correctly, but all of the check boxes display in an unchecked mode when some should display as checked.

What am I doing wrong?

Thanks in advance,

Mike B.


Rajarajeswari S [Syncfusion]
Replied On July 8, 2008 03:30 AM


Hi Mike,

Thanks for using Syncfusion products:

EditItemTemplate controls simply render the control on the column while editing. To make the checkbox to reflect he column values, we have to manually binded the checkbox with the column. Please refer the below code snippet which illustrates this:

$sfwg:GridColumnDescriptor MappingName="Checkbox">
$ItemTemplate>
$asp:CheckBox id="cbTemplate" runat="server" Checked="" AutoPostBack="true">
$/ItemTemplate>
$/sfwg:GridColumnDescriptor>

Note:
Here "$" is used instead of "<"

protected bool GetValue(GridCell container)
{
int val;
Record rowRecord = container.Row.Record;
val = Convert.ToInt32(rowRecord.GetValue("Checkbox"));
if (val == 0)
return false;
else
return true;
}

The GetValue method returns Boolean value depending upon the column values.

Please refer the sample from the below link, which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Web/6.3.0.6/Grid_Web_Template/main.htm

Please let me know if you have any other concerns.

Regards,
Raji




Administrator [Syncfusion]
Replied On September 23, 2008 12:58 PM

I seem to be having problems getting check box to work in Item Template. I have the following within Item Template of a GridColumnDescriptor

asp:CheckBox ID="chkCalculation" runat="server" Checked="<%# GetBoolField(Container) %>"

GetBoolField method returns bool value based on the value in the database. However, GetBoolField method never gets called.



Rajarajeswari S [Syncfusion]
Replied On September 25, 2008 03:40 PM

Hi Raj,

Thanks for using Syncfusion products.

Please refer the modified sample from the below link:

http://websamples.syncfusion.com/samples/Grid.Web/6.3.0.6/Grid_Web_Template/main.htm


Here CheckBox is used as ItemTemplates and are binded with values from DataSource using the GetValue method which returns bool value. Accroding to this the CheckBox checked value get differed.


Please have a look at the above and let us know if this helps you out.

Regards,
Raji


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;