Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to get the TemplateItem of a DetailsView

How to get the TemplateItem of a DetailsView

Scheduled Pinned Locked Moved ASP.NET
tutorialhtmlhelpannouncement
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b43r_3oo3
    wrote on last edited by
    #1

    Hi all, I have a DetailsView and GridView on one site. The DetailsView contains some TemplateItems with different validators like RequiredFieldValidator or RegularExpressionValidator. Example:

                            DataKeyNames="Id" DataSourceID="myDSObj" DefaultMode="Insert"
                            Caption="Add user" CaptionAlign="Left">
                            <Fields>
                                <EditItemTemplate>
                                        
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        
                                        ControlToValidate="TitelTextBox" ErrorMessage="Error!"
                                            Display="Dynamic">
                                        </asp:RequiredFieldValidator>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        
                                    </ItemTemplate>
                                </asp:TemplateField>
    

    ...

    When I want to edit entries of the GridView and confirm those with an Update HTML Button in the view, the event won't be completed cause the validators block them. So far it's all right. Now I tried to disable those validation controls via the Enable Attribute of them, but I don't know how iI can access this control via my DetailsViewInsertUser object. Example:

    protected void UserGridView_OnRowEditing(object sender, EventArgs e)
    { ((RegularExpressionValidator)UserGridView.Controls.FindControl("EMailTextBoxRegexVali

    B 1 Reply Last reply
    0
    • B b43r_3oo3

      Hi all, I have a DetailsView and GridView on one site. The DetailsView contains some TemplateItems with different validators like RequiredFieldValidator or RegularExpressionValidator. Example:

                              DataKeyNames="Id" DataSourceID="myDSObj" DefaultMode="Insert"
                              Caption="Add user" CaptionAlign="Left">
                              <Fields>
                                  <EditItemTemplate>
                                          
                                      </EditItemTemplate>
                                      <InsertItemTemplate>
                                          
                                          ControlToValidate="TitelTextBox" ErrorMessage="Error!"
                                              Display="Dynamic">
                                          </asp:RequiredFieldValidator>
                                      </InsertItemTemplate>
                                      <ItemTemplate>
                                          
                                      </ItemTemplate>
                                  </asp:TemplateField>
      

      ...

      When I want to edit entries of the GridView and confirm those with an Update HTML Button in the view, the event won't be completed cause the validators block them. So far it's all right. Now I tried to disable those validation controls via the Enable Attribute of them, but I don't know how iI can access this control via my DetailsViewInsertUser object. Example:

      protected void UserGridView_OnRowEditing(object sender, EventArgs e)
      { ((RegularExpressionValidator)UserGridView.Controls.FindControl("EMailTextBoxRegexVali

      B Offline
      B Offline
      b43r_3oo3
      wrote on last edited by
      #2

      I got it! ((RegularExpressionValidator)DetailsViewInsertUser.Controls[0].FindControl("EMailTextBoxRegexValidator")).Enabled = false;

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups