Get control into GridTemplateColumn when call EditCommand method !?

3 posts, 0 answers
  1. hongnguyenx
    hongnguyenx avatar
    20 posts
    Member since:
    Dec 2006

    Posted 15 Oct 2009 Link to this post

    Hi all,
    I have a RADGRID:

    <telerik:RadGrid ID="grdHSKT" runat="server"
                            onneeddatasource="grdHSKT_NeedDataSource" Skin="Office2007"
                            AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                            oneditcommand="grdHSKT_EditCommand">
                            <MasterTableView CommandItemDisplay="TopAndBottom" TableLayout="Auto" >
                            <PagerStyle Mode="NextPrevAndNumeric"  />
                                <Columns>
                                    <telerik:GridButtonColumn UniqueName="EditColumn" ButtonType="ImageButton" CommandName="Edit" />
                                    <telerik:GridBoundColumn DataField="TenHSKemTheo" HeaderText="Tên hồ sơ kèm theo" UniqueName="tenHSKT" DataType="System.String">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="SoBanChinh" HeaderText="Bản chính" UniqueName="banChinh" DataType="System.Int32">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="SoBanSao" HeaderText="Bản sao" UniqueName="banSao" DataType="System.Int32">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="GhiChu" HeaderText="Ghi chú" UniqueName="ghiChu" DataType="System.String">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Chọn">
                                    <ItemTemplate>
                                        <asp:Panel ID="Panel1" runat="server">
                                            <asp:CheckBox ID="cbActive" Checked="true" runat="server" AutoPostBack="true" OnCheckedChanged="CheckedChanged" />
                                        </asp:Panel>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                </Columns>
                                <EditFormSettings ColumnNumber="1" CaptionFormatString="Thay đổi hồ sơ kèm theo:">
                                    <FormTemplate>
                                       <table cellspacing="5px" cellpadding="2px">
                                        <tr>
                                            <td>Tên hồ sơ kèm theo: </td>
                                            <td>
                                                <asp:TextBox ID="txtHoSoKemTheo" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "TenHSKemTheo") %>' ></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Số bản chính: </td>
                                            <td>
                                                <asp:TextBox ID="txtSoBanChinh" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SoBanChinh") %>' > </asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Số bản sao: </td>
                                            <td>
                                                <asp:TextBox ID="txtSoBanSao" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SoBanSao") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Ghi chú: </td>
                                            <td>
                                                <asp:TextBox ID="txtMoTa" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "GhiChu") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                       </table>
                                    </FormTemplate>
                                </EditFormSettings>
                            </MasterTableView>
                            <ClientSettings AllowColumnsReorder="True">
                                <Selecting AllowRowSelect="True" />
                            </ClientSettings>
                        </telerik:RadGrid>

    And now I want to get checkbox have ID: cbActive into GridTemplateColumn when I call grdHSKT_EditCommand method to set enable property on it !!! But I don' know how to get it !!!
    Plz help me !!! Thnks so much for any help.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Oct 2009 Link to this post

    Hello,

    Try the following code snippet in order to access the checkbox in GridTemplateColumn.

    CS:
     
    protected void RadGrid1_EditCommand(object source, GridCommandEventArgs e) 
        GridDataItem editItem = (GridDataItem)e.Item; 
        CheckBox chk = (CheckBox)editItem.FindControl("cbActive"); 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. hongnguyenx
    hongnguyenx avatar
    20 posts
    Member since:
    Dec 2006

    Posted 16 Oct 2009 Link to this post

    Hi shinu,
    Thnks so much for yours help, but right nwo, I want get it into NeedDatasource method, can do it !?

    hongnguyenx
Back to Top