Hi Juergen,
Thanks
for using syncfusion product.
Query
1: How do
I achieve this? Do I need to change the ItemTemplate and
EditTemplate?
We have achieved
your requirement with the help of itemTemplate. We have set checkbox control to
the ‘Discontinued’ column.
Please refer the
below code snippets:
[ASPX]
<ItemTemplate>
<asp:CheckBox
ID="cbRowBtnTemplate"
Checked='<%#Eval("Discontinued")%>'
runat="server"
OnCheckedChanged="cbRowBtnTemplate_CheckedChanged"
AutoPostBack="true"/>
</ItemTemplate>
Query
2: How do I set and get the values from my datasource to/from the
template?
We
can set and get the Boolean values to datasource with the help of SQL update
query, in which Boolean values will be updated in datasource.
Please
refer the below code snippets:
[CS]
GridRow
gridrow = (GridRow)checkbox.Parent.Parent.Parent;
if
(gridrow.DisplayElement.Kind !=
Syncfusion.Grouping.DisplayElementKind.ColumnHeader)
{
var
discontinued = gridrow.Record.GetValue("Discontinued");
var
productID = gridrow.Record.GetValue("ProductID");
if
(checkbox != null)
{
if
(checkbox.Checked == true)
{
discontinued = true;
}
else
{
discontinued = false;
}
sqlconnection.Open();
// query to
update checkbox value to Discontinued
column
sqlcommand = new
SqlCommand("UPDATE
Products SET Discontinued = '"
+ discontinued + "'
WHERE ProductID = '"
+ productID + "'",
sqlconnection);
sqlcommand.ExecuteScalar();
sqlconnection.Close();
}
}
For your reference, we have attached
the sample.
Sample:sample.zip
Please let us know if you need any
further assistance.
Thanks,
Kavitha
Narayanan