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

Hooking up CheckBox in GridTemplateColumn to AsyncPostBackTrigger

1 Answer 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 04 May 2012, 01:47 AM
I've been scouring the threads for an example like mine and I've found bits and pieces, but haven't been able to put everything together to get what I want to work.  What I have is a grid with a checkbox in the first column that I want to perform an action on check changed.  I also have a button in the last column that puts the grid into edit mode.  Around everything I have an UpdatePanel. 

My problem is setting my triggers for only the checkbox on checkchanged.  I can set children as triggers, but that will cause the other button to trigger which I don't want.  I tried trying to programaitcally add the trigger in the ItemCreated event, but to no avail.

Relevant code as followed.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">     
            <ContentTemplate>      
                   <rad:RadGrid ID="rg" OnUpdateCommand="Update" OnNeedDataSource="BindItems"  OnItemDataBound="rg_ItemDataBound" OnPreRender="rg_PreRender" runat="server"  >            
                    <PagerStyle Position="Top" />                
                    <MasterTableView DataKeyNames="ID" CommandItemDisplay="None">               
                        <CommandItemTemplate>
                            <asp:ImageButton ID="ImageButton1" ImageUrl="/admin/images/add-record.jpg" CommandName="InitInsert" runat="server" /> Add New
                        </CommandItemTemplate>      
                        <Columns>
                            <rad:GridTemplateColumn HeaderStyle-Width="40px" HeaderText="Email">
                                <ItemTemplate>
                                    <asp:CheckBox id="cbEmail" AutoPostBack="true" OnCheckedChanged="AddToEmailList" runat="server" />                                                      
                                </ItemTemplate>
                            </rad:GridTemplateColumn>
                                          // a handful of other columns
                             <rad:GridEditCommandColumn EditText="More" HeaderStyle-Width="30" />
                     </Columns>
                    </MasterTableView>
                </rad:RadGrid>
            </ContentTemplate>       
        </asp:UpdatePanel>

Again, I want to only asynchronously postback when that checkbox is checked. Thanks for any help in advance.

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 09 May 2012, 01:05 PM
Hello Andrew,

You can use the following online demo for Partial ajaxification as bases for implementing your scenario.
http://demos.telerik.com/aspnet-ajax/ajax/examples/manager/partialajaxification/defaultvb.aspx

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or