Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

ListView EditItemTemplate

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
onseats.ky@gmail.com - 31 Oct 2007 14:51 GMT
I'm trying to get access controls in the EditItemTemplate of a list
view when the user edits an item. I need to set focus to a textbox in
this template after post back because the ListView is in a long
scrolling div. Without setting focus the user needs to scroll down the
div after postback to get to the item.

I've tried using listview.FindControl('tbxEdit') but this comes back
blank. Does anyone have any ideas?

thanks in advance.
jx.su.go@gmail.com - 31 Oct 2007 17:56 GMT
On Oct 31, 9:51 pm, onseats...@gmail.com wrote:
> I'm trying to get access controls in the EditItemTemplate of a list
> view when the user edits an item. I need to set focus to a textbox in
[quoted text clipped - 6 lines]
>
> thanks in advance.

Debug it then you can find the reason!
jx.su.go@gmail.com - 31 Oct 2007 17:57 GMT
On Oct 31, 9:51 pm, onseats...@gmail.com wrote:
> I'm trying to get access controls in the EditItemTemplate of a list
> view when the user edits an item. I need to set focus to a textbox in
[quoted text clipped - 6 lines]
>
> thanks in advance.

Debug it then you can find the reason!
onseats.ky@gmail.com - 31 Oct 2007 18:23 GMT
On Oct 31, 11:57 am, "jx.su...@gmail.com" <jx.su...@gmail.com> wrote:
> On Oct 31, 9:51 pm, onseats...@gmail.com wrote:
>
[quoted text clipped - 10 lines]
>
> Debug it then you can find the reason!

I have run through the debugger. I must be missing something obvious.
Can you be a little more specific?
rote - 31 Oct 2007 23:37 GMT
post some snippet code

> On Oct 31, 11:57 am, "jx.su...@gmail.com" <jx.su...@gmail.com> wrote:
>> On Oct 31, 9:51 pm, onseats...@gmail.com wrote:
[quoted text clipped - 14 lines]
> I have run through the debugger. I must be missing something obvious.
> Can you be a little more specific?
onseats.ky@gmail.com - 01 Nov 2007 01:07 GMT
<asp:ListView ID="lvwTemplates" runat="server"
InsertItemPosition="FirstItem"
OnItemCommand="lvwTemplates_OnItemCommand"
       OnItemCanceling="lvwTemplates_OnItemCanceling"
OnItemEditing="lvwTemplates_OnItemEditing"
OnItemInserted="lvwTemplates_OnItemInserted"
       OnItemInserting="lvwTemplates_OnItemInserting"
OnItemDeleting="lvwTemplates_OnItemDeleting"
OnItemUpdating="lvwTemplates_OnItemUpdating"
       >
       <LayoutTemplate>
           <div>
               <table>
                   <tr>
                       <td><asp:Button ID="btnNewTemplate"
runat="server" Text="New Template" OnClick="btnNewTemplate"
CausesValidation="false" /></td>
                       <td><asp:Button ID="btnBulkEdit"
runat="server" Text="Bulk Edit" OnClick="btnBulkEdit"
CausesValidation="false" /></td>
                   </tr>
               </table>

               <div id="elementViewer">
                   <asp:PlaceHolder ID="itemContainer"
runat="server" />
               </div>
           </div>
       </LayoutTemplate>
       <ItemTemplate>
           <table width="400px">
               <tr>
                   <td width="325px">
                       <asp:Label ID="lblTemplateID" runat="server"
Text="<%#((Bullsh1tTemplate)Container.DataItem).TemplateID %>"
Visible="false" />
                       <asp:Literal ID="ltrTemplate" runat="server"
Text="<%#((Bullsh1tTemplate)Container.DataItem).TemplateBody %>" />
                   </td>
                   <td><asp:Button ID="btnEdit" runat="server"
CommandName="edit" Text="Edit"/></td>
                   <td><asp:Button ID="btnDelete" runat="server"
CommandName="delete" Text="Delete" /></td>
               </tr>
           </table>
       </ItemTemplate>
       <EditItemTemplate>
           <gaia:Label ID="lblTemplateID" runat="server" Text="<
%#((Bullsh1tTemplate)Container.DataItem).TemplateID %>"
Visible="false" />
           <table width="400px">
               <tr>
                   <td width="325px">
                       <asp:TextBox ID="tbxTemplate" runat="server"
Text="<%#((Bullsh1tTemplate)Container.DataItem).TemplateBody %>" />
                       <asp:RequiredFieldValidator ID="rfvTemplate"
ControlToValidate="tbxTemplate" Text="required" runat="server"
Display="Dynamic" />
                   </td>
                   <td><asp:Button ID="btnUpdate" runat="server"
CommandName="update" Text="Update" /></td>
                   <td><asp:Button ID="btnCancel" runat="server"
CommandName="cancel" Text="Cancel" CausesValidation="false" /></td>
               </tr>
           </table>
       </EditItemTemplate>
       <InsertItemTemplate>
           <table width="250px">
               <tr>
                   <td width="325px">
                       <asp:TextBox ID="tbxTemplate" runat="server" /

                       <asp:RequiredFieldValidator ID="rfvTemplate"
ControlToValidate="tbxTemplate" Text="required" runat="server"
Display="Dynamic" />
                   </td>
                   <td><asp:Button ID="btnInsert" runat="server"
CommandName="insert" Text="Save" /></td>
                   <td><asp:Button ID="btnCancel" runat="server"
CommandName="cancel" Text="Cancel" CausesValidation="false" /></td>
               </tr>
           </table>
       </InsertItemTemplate>
       <EmptyDataTemplate>
           This rule is currently empty
       </EmptyDataTemplate>
   </asp:ListView>

c# code

protected void lvwTemplates_OnItemEditing(object sender,
ListViewEditEventArgs e)
{
           ListView listView = (ListView)sender;
           TextBox tbx =
listView.FindControl("tbxTemplate")
}

In the sample above tbx gets set to null

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.