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

RadGrid templated control

3 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sals
Top achievements
Rank 1
Sals asked on 23 Dec 2008, 09:12 PM
Hello,

Does anyone have an example of adding the checkbox or any control in a composite server control with RadGrid?  Or if you have any suggestion please let me know.

Thank you,
-Sal

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Dec 2008, 05:02 AM
Hi,

I hope you are trying to add a CheckBox to GridTemplateColumn in code behind. If so you can try the following code snippet.

ASPX:
 <telerik:GridTemplateColumn HeaderText="TempCol" UniqueName="TempCol" > 
             </telerik:GridTemplateColumn> 

CS:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            CheckBox chkbx = new CheckBox(); 
            chkbx.ID = "CheckBox1"
            item["TempCol"].Controls.Add(chkbx); 
        } 
    } 

Shinu
0
Sals
Top achievements
Rank 1
answered on 30 Dec 2008, 04:58 PM
Hi Sinu:

Here is the ASPX code that I need to use in my custom server control using RadGrid.   Can you please give me an idea or a way that how can I put all these in to code behind in a server control.


<asp:GridView>
        <Columns>
         <asp:TemplateField HeaderText="My Grid Test">

         <ItemTemplate>
           <asp:CheckBox runat="server" ID="chkBox" OnCheckedChanged="chkBoxCheckChanged" Checked = '<%# Eval("value") %>'
          AutoPostBack="True"  Enabled="false"/>
       </ItemTemplate>
       </asp:TemplateField>
       
          <asp:BoundField DataField="TestField1" HeaderText="Test 1" />
          <asp:BoundField DataField="TestField2" HeaderText="Test 2" />

        </Columns>

</asp:GridView>


Thank you
-Sal
0
Princy
Top achievements
Rank 2
answered on 31 Dec 2008, 04:38 AM
Hello,

You can go through the following help link to understand how to create TemplateColumns programmatically. Refer to the section - 'Creating template columns programmatically' in the help document.
Programmatic creation

Thanks
Princy.
Tags
Grid
Asked by
Sals
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sals
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or