- Home
- Forum
- ASP.NET Web Forms (Classic)
- checkbox in grid does not display correctly
checkbox in grid does not display correctly
- Jul 7, 2008 08:59 PM UTC
- Sep 25, 2008 07:40 PM UTC
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.
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.
SIGN IN To post a reply.
3 Replies
RS
Rajarajeswari S
Syncfusion Team
July 8, 2008 07:30 AM UTC
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
AD
Administrator
Syncfusion Team
September 23, 2008 04:58 PM UTC
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.
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.
RS
Rajarajeswari S
Syncfusion Team
September 25, 2008 07:40 PM UTC
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
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
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
MB Mike Bourne
- Jul 7, 2008 08:59 PM UTC
- Sep 25, 2008 07:40 PM UTC