Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Dealing with a Checkbox Column in a WebGrid
posted

I have added a Checkbox column to the webgrid but how can I access the checkboxes on postback to the server?  My grid has 2 columns one is the checkbox and one is the display text.  I have bound the display text column to the datasource but where do I bind the checkbox column to the datasource?  How can I set a hidden value of the checkbox so on post back I can iterate through the rows of the grid and pluck out the hidden values when a checkbox is checked?

  • 115
    Verified Answer
    posted

    Finally got this thing figured out.  On the presentation side I had to set the

     

    <ValueList DataMember="hiddenvalue" DisplayMember="hiddenvalue"></ValueList>

    for the Checkbox column in the grid.

    Then to access the checked values on the server side I did the following:

    foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow gvr in uwgParameters.Rows)
    {
       
    if (Convert.ToBoolean(gvr.Cells[0].Value))
        {
           
    Filter = Filter + gvr.DataKey + ",";
        }
    }

    Hope this helps someone.