PC Review


Reply
Thread Tools Rate Thread

DetailsView Problem

 
 
Chris
Guest
Posts: n/a
 
      26th Nov 2007
In ASP.NET, I've created a DetailsView control, unbound. There are a
few textboxes in it, and I want to be able to enumerate through all
the rows, and get the values of the textboxes in those rows. Any
ideas how I should go about doing this?
 
Reply With Quote
 
 
 
 
Duy Lam
Guest
Posts: n/a
 
      26th Nov 2007
Chris wrote:
> In ASP.NET, I've created a DetailsView control, unbound. There are a
> few textboxes in it, and I want to be able to enumerate through all
> the rows, and get the values of the textboxes in those rows. Any
> ideas how I should go about doing this?


When (what event) does you want to be able to enumerate controls in row ?
For example: I can enumerate controls in ItemDataBound event

[Design]

<asp:detailview onitemdatabound="OnItemDataBound">
<itemTemplate>
<asp:textbox id="txtName" text='<%# Eval("Name") %>'>
<Br /><asp:textbox id="txtAge" text='<%# Eval("Age") %>'>
<Br /><asp:textbox id="txtPosition" text='<%# Eval("Position") %>'>
</itemTemplate>
</asp:detailview>

[code behind]

protected void OnItemDataBound(object sender,DataListItemEventArgs e) {
if( e.Item.ItemType == ListItemType.AlternativeItem || e.Item.ItemType
== ListItemType.Item ) {
Textbox txt1 = e.Item.FindControl("txtName") as Textbox;
Textbox txt2 = e.Item.FindControl("txtAge") as Textbox;
Textbox txt3 = e.Item.FindControl("txtPosition") as Textbox;
// do anything you want to these textbox
txt1.Text = "Mr. "+txt.Text;
}
}

Hope this help

--
Duy Lam Phuong
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Customvalidator problem within Detailsview B. Chernick Microsoft ASP .NET 2 5th Dec 2007 08:51 PM
DetailsView problem chenhong Microsoft ASP .NET 1 24th Jul 2007 06:21 PM
DetailsView problem drasko Microsoft ASP .NET 0 18th Oct 2006 12:52 PM
Detailsview Problem Seth Bourne Microsoft ASP .NET 0 5th Oct 2006 04:41 PM
DetailsView Problem Maury Microsoft ASP .NET 2 22nd Mar 2006 01:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.