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

[Solved] How to handle Event with Grid with User Control

3 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dinesh
Top achievements
Rank 1
Dinesh asked on 12 May 2008, 07:11 AM
Hi,

I have create a page (aspx with Rad Grid) and another web control with (ascx).

The ascx will be used to add/edit data in grid.

        <EditFormSettings EditFormType="WebUserControl" UserControlName="BoardPositionDetails.ascx"
        </EditFormSettings> 
 

In WebUserControl I have used a RadTreeView. I am going to use on demand loading with rad tree. My problem is any event of radtree does not call the code behind event methods.

Is this possible to do ?

Thanks in advance

Dinesh

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 14 May 2008, 08:12 AM
Hi Dinesh,

Yes, it is possible.

Please examine the attached project.

It should give you the basic idea of the implementation.

Regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dinesh
Top achievements
Rank 1
answered on 15 May 2008, 03:31 AM
Hi,

Thanks for the reply. I have done it in same way. The coding is as follows. And we are using RadControls for ASP.NET Q2 2007.

After that I try it with template mode in RadGrid. It also dosn't work.
Here is the aspx rad grid code.

<radG:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
            GridLines="None" OnItemCreated="RadGrid1_ItemCreated"
            <ExportSettings> 
                <Pdf PageBottomMargin="" PageFooterMargin="" PageHeaderMargin="" PageHeight="11in" 
                    PageLeftMargin="" PageRightMargin="" PageTopMargin="" PageWidth="8.5in" /> 
            </ExportSettings> 
            <MasterTableView DataKeyNames="BOARDPOSITIONID" DataSourceID="SqlDataSource1" CommandItemDisplay="Top"
                <RowIndicatorColumn Visible="False"
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Resizable="False" Visible="False"
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <radG:GridBoundColumn DataField="BOARDPOSITIONID" DataType="System.Guid" HeaderText="BOARDPOSITIONID" 
                        ReadOnly="True" SortExpression="BOARDPOSITIONID" UniqueName="BOARDPOSITIONID"
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="NAME" HeaderText="NAME" SortExpression="NAME" UniqueName="NAME"
                    </radG:GridBoundColumn> 
                    <radG:GridBoundColumn DataField="DESCRIPTION" HeaderText="DESCRIPTION" SortExpression="DESCRIPTION" 
                        UniqueName="DESCRIPTION"
                    </radG:GridBoundColumn> 
                    <radG:GridEditCommandColumn> 
                    </radG:GridEditCommandColumn> 
                </Columns> 
                <EditFormSettings EditFormType="Template"
                    <EditColumn UniqueName="EditCommandColumn1"
                    </EditColumn> 
                    <FormTemplate> 
                        <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label> 
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox> 
                        <br /> 
                        <asp:Label ID="Label2" runat="server" Text="Description"></asp:Label> 
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox> 
                        <br /> 
                        <asp:Label ID="Label3" runat="server" Text="Permission"></asp:Label><br /> 
                        <radT:RadTreeView ID="RadTreeView1" runat="server" AutoPostBack="True" OnNodeExpand="RadTreeView1_NodeExpand" 
                                        OnClientNodeChecked="ClientNodeChecked"
                        </radT:RadTreeView> 
                        <br /> 
                        <br /> 
                        <asp:Button ID="Button1" runat="server" Text="Insert" CommandName="PerformInsert" OnClick="Button1_Click" /> 
                        <asp:Button ID="Button3" runat="server" Text="Update" CommandName="Update" /> 
                        <asp:Button ID="Button2" runat="server" Text="Cancel" CommandName="Cancel"/> 
                    </FormTemplate> 
                </EditFormSettings> 
            </MasterTableView> 
            <AJAXLoadingTemplate> 
            </AJAXLoadingTemplate> 
        </radG:RadGrid> 



Here is the code behind code
on Page Load

            n = new RadTreeNode("Node 1", "A"); 
            n.ExpandMode = ExpandMode.ServerSideCallBack; 
            rtv.Nodes.Add(n); 
 
            n = new RadTreeNode("Node 2", "B"); 
            n.ExpandMode = ExpandMode.ServerSideCallBack; 
            rtv.Nodes.Add(n); 
 
            n = new RadTreeNode("Node 3", "C"); 
            n.ExpandMode = ExpandMode.ServerSideCallBack; 
            rtv.Nodes.Add(n); 
 
            n = new RadTreeNode("Node 4", "D"); 
            n.ExpandMode = ExpandMode.ServerSideCallBack; 
            rtv.Nodes.Add(n); 

On Expand Event

        protected void RadTreeView1_NodeExpand(object o, RadTreeNodeEventArgs e) 
        { 
            string test = e.NodeClicked.Text; 
        } 

This is work If I change

// n.ExpandMode = ExpandMode.ServerSideCallBack; 
 n.ExpandMode = ExpandMode.ServerSide; 

Will it be a problem of the version of rad controls with us ? (RadControls for ASP.NET Q2 2007.)

Thank You

Dinesh
0
Simon
Telerik team
answered on 16 May 2008, 03:35 PM
Hi Dinesh,

As I examined your code, I noticed that you are using RadTreeView Classic. Unfortunately, the NodeExpand event in this will not fire and this is a limitation of the control.

Please use RadTreeView for ASP.NET AJAX instead, as it works normally in the same case.

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Dinesh
Top achievements
Rank 1
Answers by
Simon
Telerik team
Dinesh
Top achievements
Rank 1
Share this question
or