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
570
WebGrid's problem
posted

How can I find control which it is in the WebGrid's cell by c#?  There is page code at below:

<igtbl:TemplatedColumn>
    <HeaderStyle HorizontalAlign="center" />
        <HeaderTemplate>
            <asp:CheckBox ID="cbAll" runat="server" onclick="SelectAll(this.checked,this.id);" />
        </HeaderTemplate>
        <CellStyle HorizontalAlign="center" />
        <CellTemplate>
            <asp:CheckBox ID="cbSingle" runat="server" onclick="SelectSingle(this.checked,this.id);" />
        </CellTemplate>
</igtbl:TemplatedColumn>

I wish find which control's id is cbSingle in WebGrid's function that named DataBound, how can I do?

Parents
No Data
Reply
  • 2501
    Suggested Answer
    posted

    Hello,

    The following code demonstrates how to use the FindControl method to find a control in the cell of a WebGrid's TemplatedColumn:

       // Cast the Column to a Templated Column object 
       TemplatedColumn tc = (TemplatedColumn)UltraWebGrid1.Bands(0).Columns(0);
       
        // Create a Templated Column CellItem object for each row
        CellItem item = (CellItem)tc.CellItems(e.Row.BandIndex);
       
        // Create a CheckBox object to find the Control 
        CheckBox chkbx = (CheckBox)item.FindControl("cbSingle");

    Once you have the object, then implement the rest of your code.  Please let me know if this is helpful.

    Sincerely,
    Mike D.

     

     

Children