Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > User Controls-MasterPages and finding TextBox in DataList EditItemTemplate

Reply
Thread Tools

User Controls-MasterPages and finding TextBox in DataList EditItemTemplate

 
 
Hillbilly
Guest
Posts: n/a
 
      09-02-2008
Anybody have any sage advice on this frustrating "feature" of ASP.NET? I
have a TextBox in the EditItemTemplate of a DataList I can't seem to find
for some reason that is I believe related to the imfamous complexity and
undocumented vagaries of user controls and MasterPages which are also a type
of user control.

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      09-02-2008
Typically, you need to access template controls in one of the item events,
like ItemCreated or ItemDataBound. Event parameters provide a reference to
the item, something like e.Item. To detect EditItem, you need to check
ItemType or check if (e.Item is ListItemType.EditItem). Once you have
detected EditItem, you can use e.ItemFindControl("myTextBox") to get to the
textbox.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Hillbilly" <(E-Mail Removed)> wrote in message
news:O0zWW$(E-Mail Removed)...
> Anybody have any sage advice on this frustrating "feature" of ASP.NET? I
> have a TextBox in the EditItemTemplate of a DataList I can't seem to find
> for some reason that is I believe related to the imfamous complexity and
> undocumented vagaries of user controls and MasterPages which are also a
> type of user control.



 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      09-02-2008
there is nothing really complex about it. html (and asp.net) is a
parent/child (tree) data structure. recursion was invented to handle this
common data structure.

var list = ControlWalker(this, ctl => ctl.ID == "textboxid");
....

public List<Control> ControlWalker(
Control ctl,
Predicate<Control> matcher)
{
var list = new List<Control>();
if (matcher(ctl)) list.Add(ctl);
for (int i=0; i < ctl.Controls.Count; ++i)
{
var childList = ControlWalker(
ctl.Controls[i],matcher);
if (childList.Count > 0)
list.AddRange(childList);
}
return (list);
}


-- bruce (sqlwork.com)


"Hillbilly" wrote:

> Anybody have any sage advice on this frustrating "feature" of ASP.NET? I
> have a TextBox in the EditItemTemplate of a DataList I can't seem to find
> for some reason that is I believe related to the imfamous complexity and
> undocumented vagaries of user controls and MasterPages which are also a type
> of user control.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a user control as EditItemTemplate in a DataList Hans Merkl ASP .Net 3 03-22-2010 02:22 PM
Not updated Textbox value inside a datalist editItemTemplate etantonio@gmail.com ASP .Net Web Controls 1 09-27-2005 10:21 AM
Not updated Textbox value inside a datalist editItemTemplate etantonio@gmail.com ASP .Net 1 09-27-2005 10:21 AM
Entering DataList EditItemTemplate from Outside of the DataList Luis Esteban Valencia ASP .Net 1 01-06-2005 07:32 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM



Advertisments