Solved

Find control inside accordion using c#

Posted on 2008-10-10
10
6,956 Views
Last Modified: 2013-12-17
hello experts,

       i am using a datagrid inside accordion pane.I want to bind the dagrid to a datasource for which i need to find the control inside the
content template of accordion.

How to find the control???

URGENT..Thanks.

Please check the snippet for my aspx page.
<ajaxToolkit:Accordion ID="acc1" runat="server" SelectedIndex="1" FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250" AutoSize="None" RequireOpenedPane="false" HeaderCssClass="HeaderTab">
                                                    <HeaderTemplate>
                                                        Select Distributor</HeaderTemplate>
                                                    <ContentTemplate>
                                                        <asp:DataGrid ID="dgReports" GridLines="None" CellSpacing="0" CellPadding="0" ShowHeader="false" AutoGenerateColumns="False" AllowSorting="false" runat="server" DataKeyField="ProjectID">
                                                            <Columns>
                                                                <asp:TemplateColumn Visible="False" HeaderText="Project ID">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblProjectID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.USER_NM") %>'>
 
                                                                        </asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateColumn>
                                                                <asp:TemplateColumn>
                                                                    <ItemTemplate>
                                                                        <ul style="list-style-type: square">
                                                                            <li><a href='IssueReport.aspx?ProjectId=<%# DataBinder.Eval(Container.DataItem, 
"ProjectId")%>'>
                                                                                <%# DataBinder.Eval(Container.DataItem, "USER_NM")%>
                                                                            </a></li>
                                                                        </ul>
                                                                    </ItemTemplate>
                                                                </asp:TemplateColumn>
                                                            </Columns>
                                                        </asp:DataGrid>
                                                    </ContentTemplate>
                                                </ajaxToolkit:Accordion>

Open in new window

0
Comment
Question by:srk1982
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 3

Expert Comment

by:trunghieubkit
ID: 22685238
Your datagrid control's name is dgReports

You can assign it's datasource as below

        DataViewManager dsView;
        dgReports.DataSource = dsView;
        dgReports.DataMember = tablename;


0
 

Author Comment

by:srk1982
ID: 22685251
hi trunghieubkit,

     My problem is not in assigning the datasource to datagrid
  I want to find the control inside accordion....

i am using this code..but it is not woking...

        DataSet dsDistibutors = Fund.GetAllDistibutor();
        DataGrid dg = (DataGrid)accordion1.FindControl("dgReports");
        dg.DataSource = dsDistibutors;
        dg.DataBind();
0
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22685377
hi srk1982,

bind the gridview inside Accordion1_ItemDataBound...

Refer this link...

http://aspalliance.com/1674_Complex_Data_Binding_with_the_Accordion_Control.all
protected void Accordion1_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
        {
            if (e.ItemType != AjaxControlToolkit.AccordionItemType.Content)
                return;
            GridView grid = e.AccordionItem.FindControl("GridView1") as GridView;            
            grid.DataSource = "Your DataSet";
            grid.DataBind();
 
        }

Open in new window

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:srk1982
ID: 22685585
hi sijishJohn,

  I did the following code in  snippet. But the Itemdatabound event is not at all firing.
Am i missing anything ????

please help.....thanks,..
 protected void acc1_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
    {
        if (e.ItemType != AjaxControlToolkit.AccordionItemType.Content)
            return;
        DataSet dsDistibutors = Fund.GetAllDistibutor();
        DataGrid grid = e.AccordionItem.FindControl("dgReports") as DataGrid;
        if (grid == null) return;
        grid.DataSource = dsDistibutors;
        grid.DataBind();
    }
 
 
 
 <ajaxToolkit:Accordion ID="acc1" runat="server" SelectedIndex="1" FadeTransitions="true" 
                                                FramesPerSecond="40" TransitionDuration="250" AutoSize="None" RequireOpenedPane="false" 
                                                HeaderCssClass="HeaderTab" >
                                                    <HeaderTemplate>
                                                        Select Distributor</HeaderTemplate>
                                                    <ContentTemplate>
                                                        <asp:DataGrid ID="dgReports" GridLines="None" CellSpacing="0" CellPadding="0" ShowHeader="false" AutoGenerateColumns="False" AllowSorting="false" runat="server" DataKeyField="ProjectID">
                                                            <Columns>
                                                                <asp:TemplateColumn Visible="False" HeaderText="Project ID">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblProjectID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.USER_NM") %>'>
 
                                                                        </asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateColumn>
                                                                <asp:TemplateColumn>
                                                                    <ItemTemplate>
                                                                        <ul style="list-style-type: square">
                                                                            <li><a href='IssueReport.aspx?ProjectId=<%# DataBinder.Eval(Container.DataItem, 
"ProjectId")%>'>
                                                                                <%# DataBinder.Eval(Container.DataItem, "USER_NM")%>
                                                                            </a></li>
                                                                        </ul>
                                                                    </ItemTemplate>
                                                                </asp:TemplateColumn>
                                                            </Columns>
                                                        </asp:DataGrid>
                                                    </ContentTemplate>
                                                </ajaxToolkit:Accordion>

Open in new window

0
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22685714
you have to bind the Accordion control in the page_load event..
then only its temdatabound event will fire...

eg.
string Name = "Experts-exchange";
Accordion1.DataSource = Name;
Accordion1.DataBind();
0
 
LVL 4

Accepted Solution

by:
sijishJohn earned 500 total points
ID: 22685745
You have to register the ItemDataBound event like this..
<ajaxToolkit:Accordion ID="acc1" runat="server" SelectedIndex="1" FadeTransitions="true" 
                                                FramesPerSecond="40" TransitionDuration="250" AutoSize="None" RequireOpenedPane="false" 
                                                HeaderCssClass="HeaderTab"   OnItemDataBound="acc1_ItemDataBound">

Open in new window

0
 

Author Comment

by:srk1982
ID: 22685939
hi sijishJohn,

     I accomplished the task, by doing the code in snippet.
public void accordion()
    {
        DataSet dsDistibutors = Fund.GetAllDistibutor();
        AccordionPane ap1 = new AccordionPane();
        ap1.HeaderContainer.Controls.Add(new LiteralControl("Select Distributor"));
        ap1.ContentContainer.Controls.Add(GetRadioButtonList());
        Accordion1.Panes.Add(ap1);
    }
    private RadioButtonList GetRadioButtonList()
    {
        DataSet dsDistibutors = Fund.GetAllDistibutor();
        RadioButtonList RBList = new RadioButtonList();
        RBList.DataSource = dsDistibutors;
        RBList.DataTextField = "USER_NM";
        RBList.DataValueField = "USER_NM";
        RBList.DataBind();
        RBList.AutoPostBack = true;
        return RBList;
    }

Open in new window

0
 

Author Closing Comment

by:srk1982
ID: 31504928
Thanks for u r contribution
0
 
LVL 4

Expert Comment

by:sijishJohn
ID: 22685963
Good Work...Keep going..
0
 

Author Comment

by:srk1982
ID: 22686007
hi sijishJohn,

I have posted one question in this link.
This post is the continuation of this post. For gettign the value of selected item of radiobuttonlist in accordion.

   http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_23803820.html

Please do help for this also...
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question