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 / March 2008

Tip: Looking for answers? Try searching our database.

Different DetailsView templates for items in a GridView.  Is it possible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bogdan - 21 Mar 2008 18:01 GMT
Hi,

Can a single GridView be 'connected' to DetailsView that renders itself
differently based on the currently selected row?
I have a GridView with rows that could be displayed in the same way in the
view (like a report) but when a user wants to edit/insert items I'd like to
show a different layout and [possibly] different controls based on the
selected item type.  For example, for some items I'd like to provide text
boxes and for others I'd like to provide dropdownlists, extra buttons, etc.

I'd like to have the DetailsView displayed on the same page as the GridView.

Can this be done?  If not, any recommendations for alternative solutions?

Thanks,
Bogdan
Paul Shapiro - 21 Mar 2008 21:28 GMT
You can use Templates for the DetailsView to specify different controls for
display and editing.

> Hi,
>
[quoted text clipped - 11 lines]
>
> Can this be done?  If not, any recommendations for alternative solutions?
bogdan - 21 Mar 2008 22:37 GMT
But how do I do it dynamically?  I could define a single template per field
in DetailsView.  What I'd like to do is to (I think) have different
templates for the same fields based on some criteria.
For example, I get an 'item' from db.  The 'item' has a column called
'content'.  The content (which is a text) can represent a filename, a
paragraph of text, or a line of text.  It all depends on a value in another
column of the item.
So, if I a filename is selected in the 'parent' GridView I'd like the
DetailsView display a short text box and have a corresponding validator
attached to it.  On the other hand, if a paragraph is selected in the
GridView I'd like DetailsView to display a multiline text box and no
validator.

The item's remaining fields and their templates would identical in all
cases.

Thanks,
Bogdan

> You can use Templates for the DetailsView to specify different controls
> for display and editing.
[quoted text clipped - 14 lines]
>>
>> Can this be done?  If not, any recommendations for alternative solutions?
Paul Shapiro - 22 Mar 2008 13:01 GMT
You might want to rethink the db design a bit. One field should really have
one meaning, not dependent on the values of other fields, like the meaning
of content depends on content type in this example.

I'm pretty new at asp.net development, so you might get better suggestions
from people with more experience. One possibility for alternate templates
would be to include the same field as many times as you have desired control
types. Then hide all but the appropriate control depending on the content
type.

> But how do I do it dynamically?  I could define a single template per
> field in DetailsView.  What I'd like to do is to (I think) have different
[quoted text clipped - 34 lines]
>>> Can this be done?  If not, any recommendations for alternative
>>> solutions?

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.