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
360
Check Box in Ultr Web Grid
posted

Hi all

i have a check box in one of Template columns of Ultra Webgrid

when user checks the check box i want to check on CheckChanged event that how much Chec boxes are checked. I have done this thing on Server Side. One problem is that how i can get the check box . Means, Like in Grid View we do some thing like this

foreach (GridViewRow row in GridView1.Rows)

{

     CheckBox chk  = (CheckBox) row.FindControl("checkBox")  (how i can do this thing in ultra web grid)

     if(chk.Checked)

     {

                    //Do some thing

      }

}

 

2nd thing is that is there any other way i can do this thing instead of Going back to Server each time????

Parents
No Data
Reply
  • 28464
    Verified Answer
    posted

     Hello Muhammad,

    I believe it is possible to have this scenario. Just remove the postback event on check for each checkbox on the template, set a general "Ok" or "Submit" button below the grid and use the following code to obtain the checked nodes:

    <igtbl:TemplatedColumn Key="CustomerID">
        <CellTemplate>
            <asp:CheckBox runat="server" ID="CheckBox1" />
        </CellTemplate>
    </igtbl:TemplatedColumn>
                       
    protected void Button1_Click(object sender, EventArgs e)
        {
            TemplatedColumn column = (TemplatedColumn) UltraWebGrid1.Columns.FromKey("CustomerID");
            int counter = 0;
           
            foreach (CellItem item in column.CellItems)
            {
                CheckBox checkBox = (CheckBox) item.FindControl("CheckBox1");
                if (checkBox.Checked)
                {
                    Page.Response.Write("Checkbox on row " + counter.ToString() + " is checked");
                }

                counter = counter + 1;
            }
        }

     

    Please, let me know if this helps.

Children