Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCode Behind CanCode Behind Can't Reference DropDownLists in InsertItemTemplate from FormView
Previous
 
Next
New Post
7/7/2010 6:23 PM
 
I have been trying to learn to develop my own module for some time now.  Been all over Michael Washington's web site and have 4-5 books on module development.  I've made some progress, but continue to encounter hurdles and I have to figure ways around because usually I can't get over them!  I'm stuck at one that I can't figure out and need some help!

I'm using C# & LINQ.  I've got the standard functionality working, but am having to modify some of the data before posting to the database.  Specifically I'm trying to get 3 DropDownLists to gather date information (day, month, year) and then I want to concatenate them together for my date field.  I am able to alter data correctly before posting to the database (I've tested with simple numbers), but I'm having trouble with the code behind recognizing my DropDownList ID's.  I've checked the file inheritance and everything is configured correctly.  Somehow just staring at the computer for several hours doesn't help me either.

I'm using a FormView on the page.  In the source of the FormView I have 3 template areas "EditItemTemplate", "InsertItemTemplate", & "Itemtemplate" where the code for each view is located.  I've got these 3 DropDownLists inside of the InsertItemTemplate area, but cannot get them to show up in the Intellisense or "Code Hinting" in the code behind when typing.  Also, if I type them all the way out, it still doesn't recognize them. 

I just noticed that If I move these DropDownLists outside of the FormView region that the code behind then recognizes them as normal and they show up in the intellisense.  Obviously, I need for them to be inside of the "InsertItemTemplate" in order to make it work. 

Do you know of any way for the code behind to reference DropDownLists inside of the template areas in a FormView?

As always, thanks for your time!

Regards,

Clint

_____________________________________________________________

Here's the InsertItemTemplate Code

 <InsertItemTemplate>
          
       Date:
          <asp:DropDownList ID="DateMonth" runat="server" Text='<%# Bind("Date") %>' >
            <asp:ListItem Value="01">Jan</asp:ListItem>
            <asp:ListItem Value="02">Feb</asp:ListItem>
            <asp:ListItem Value="03">Mar</asp:ListItem>
            <asp:ListItem Value="04">Apr</asp:ListItem>
            <asp:ListItem Value="05">May</asp:ListItem>
            <asp:ListItem Value="06">Jun</asp:ListItem>
            <asp:ListItem Value="07">Jul</asp:ListItem>
            <asp:ListItem Value="08">Aug</asp:ListItem>
            <asp:ListItem Value="09">Sep</asp:ListItem>
            <asp:ListItem Value="10">Oct</asp:ListItem>
            <asp:ListItem Value="11">Nov</asp:ListItem>
            <asp:ListItem Value="12">Dec</asp:ListItem>
          </asp:DropDownList>

        <asp:DropDownList ID="DateDay" runat="server">
            <asp:ListItem>01</asp:ListItem>
            <asp:ListItem>02</asp:ListItem>
            <asp:ListItem>03</asp:ListItem>
            <asp:ListItem>04</asp:ListItem>
            <asp:ListItem>05</asp:ListItem>
            <asp:ListItem>06</asp:ListItem>
            <asp:ListItem>07</asp:ListItem>
            <asp:ListItem>08</asp:ListItem>
            <asp:ListItem>09</asp:ListItem>
            <asp:ListItem>10</asp:ListItem>
            <asp:ListItem>11</asp:ListItem>
            <asp:ListItem>12</asp:ListItem>
            <asp:ListItem>13</asp:ListItem>
            <asp:ListItem>14</asp:ListItem>
            <asp:ListItem>15</asp:ListItem>
            <asp:ListItem>16</asp:ListItem>
            <asp:ListItem>17</asp:ListItem>
            <asp:ListItem>18</asp:ListItem>
            <asp:ListItem>19</asp:ListItem>
            <asp:ListItem>20</asp:ListItem>
            <asp:ListItem>21</asp:ListItem>
            <asp:ListItem>22</asp:ListItem>
            <asp:ListItem>23</asp:ListItem>
            <asp:ListItem>24</asp:ListItem>
            <asp:ListItem>25</asp:ListItem>
            <asp:ListItem>26</asp:ListItem>
            <asp:ListItem>27</asp:ListItem>
            <asp:ListItem>28</asp:ListItem>
            <asp:ListItem>29</asp:ListItem>
            <asp:ListItem>30</asp:ListItem>
            <asp:ListItem>31</asp:ListItem>
           </asp:DropDownList>
      
        <asp:DropDownList ID="DateYear" runat="server">
                <asp:ListItem>2010</asp:ListItem>
        </asp:DropDownList>
        
              
        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" Text="Insert" />
        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server"
            CausesValidation="False" CommandName="Cancel" Text="Cancel" />

    </InsertItemTemplate>



 
New Post
7/7/2010 7:31 PM
 
You will have to use "FindControls" on the form view to get access to the drop down lists that are contained inside of it. Something like this

DropDownList ddlMyList = (DropDownList)myFormView.FindControls("MyControlId");

-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesCode Behind CanCode Behind Can't Reference DropDownLists in InsertItemTemplate from FormView


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out