This is a migrated thread and some comments may be shown as answers.

Checkbox parameter value not being picked up

8 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neil N
Top achievements
Rank 1
Veteran
Iron
Neil N asked on 11 Apr 2011, 05:04 PM
I've got a grid which has an EditForm:

<EditFormSettings EditFormType="Template">
<FormTemplate>      
<asp:CheckBox runat="server" ID="chkPrintedPaper" Text="Printed Paper" Checked='<%# ConvertChecked(Eval("PrintedPaper")) %>' />
 </FormTemplate>
</EditFormSettings>

ConvertChecked is a code-behind function which turns 1, 0, NULL into True, False, False respectively.

For my insert command:

InsertCommandType="StoredProcedure" InsertCommand="csp_reg_saveEMSite"                    
<InsertParameters>                   
    <asp:Parameter Name="PrintedPaper" Type="boolean" />
</InsertParameters>

When I do a trace, the value of chkPrintedPaper isn't picked up (other fields, all textboxes, are fine).  What do I need to do here?

8 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Apr 2011, 06:06 PM
Hi Neil Negandhi ,

<asp:CheckBox ID="ChkTemp" runat="server"
  Visible='<%#  Convert.ToString(Eval("PrintedPaper")) == "1" ? Convert.ToBoolean("true") : Convert.ToBoolean("false") %>'></asp:CheckBox>

i hope this code will help u.

let me know if any concern.

Thanks,
Jayesh Goyani
0
Neil N
Top achievements
Rank 1
Veteran
Iron
answered on 11 Apr 2011, 06:15 PM
Doesn't this just affect the Visible property of the checkbox? What does this have to do with the PrintedPaper insert parameter not being picked up?
0
Neil N
Top achievements
Rank 1
Veteran
Iron
answered on 13 Apr 2011, 09:45 PM
Any help here?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Apr 2011, 06:51 AM
hi Neil Negandhi,

please elaborate the scenario.

Thanks,
Jayesh Goyani
0
Neil N
Top achievements
Rank 1
Veteran
Iron
answered on 14 Apr 2011, 12:32 PM
Elaborate how?  The PrintedPaper parameter is not being populated when the user tries to insert a record in the database.
0
Vasil
Telerik team
answered on 18 Apr 2011, 01:37 PM
Hello Neil,

PrintedPaper's value is not inserted back to the database because Eval is one way binding.

You have two options:
1) Use Bind instead of Eval however you will need to keep the values in the database as Boolean. Or just use GridCheckBoxColumn. Check this demo for example: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx
2) Handle RadGrid's InsertCommand event. Parse manually the value of the chkPrintedPaper and then insert the record. Check the code of this demo for example:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx

Greetings,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Neil N
Top achievements
Rank 1
Veteran
Iron
answered on 26 Apr 2011, 04:45 PM
Thanks. I changed the data types to boolean and used Bind and it worked.  Related question: Same scenario, I add a new record and while in edit mode I set a filter. When the filter action takes place I get a: Conversion from type 'DBNull' to type 'Boolean' is not valid.  referring to the checkboxes.  Not sure why.  This is in my ItemCommand event:

    Case "InitInsert"
        If grdSites.MasterTableView.FilterExpression <> "" Then
            clearFilters()
        End If
 
        e.Canceled = True
 
        'Prepare an IDictionary with the predefined values
        Dim newValues As System.Collections.Specialized.ListDictionary = New System.Collections.Specialized.ListDictionary()
        newValues("PrintedPaper") = False
        newValues("Paper") = False
        newValues("Plastic") = False
        newValues("Steel") = False
        newValues("Aluminum") = False
        newValues("Glass") = False
 
        'Insert the item and rebind
        e.Item.OwnerTableView.InsertItem(newValues)
 
End Select
0
Vasil
Telerik team
answered on 02 May 2011, 09:37 AM
Hello Neil,

Try to set default value for the database column. It seems that when you try to filter the column value is still null regardless of that the column type is not nullable.

Greetings,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Neil N
Top achievements
Rank 1
Veteran
Iron
Answers by
Jayesh Goyani
Top achievements
Rank 2
Neil N
Top achievements
Rank 1
Veteran
Iron
Vasil
Telerik team
Share this question
or