Sample Code: Using DetailsView in Whidbey

The Datagrid/DataList/Repeater control in ASP.NET had provided the flexibility and ease to show the data in a formatted manner. However sometimes the requirement is to flip the data from conventional horizontal layout to vertical layout and page a single record per page

This is possible using Datalist/Repeater/Datagrid but requires some amount of code (basically its not as easy as drag and drop and setting certain properties).

Some of my samples based on this requirement were as follows:

Building a Navigation System in ASP.NET

Use ViewState to display one record per page and also navigate

DetailsView control in Whidbey is one of the controls which can be used to give this kind of layout without any extra coding required

The code is as below

<asp:detailsview id="Detailsview1" runat="server" datasourceid ="Sqldatasource1" Allowpaging="true">

</asp:detailsview>

<asp:sqldatasource id="Sqldatasource1" runat="server"

selectcommand = "Select * from Employees"

selectcommand = "Select * from Employees"

connectionstring="Server=localhost;uid=sa;password=;database=northwind">

connectionstring="Server=localhost;uid=sa;password=;database=northwind">

</asp:sqldatasource>

Simple isnt it!!!! :-)

Simple isnt it!!!! :-)

</asp:detailsview>

<asp:sqldatasource id="Sqldatasource1" runat="server"

selectcommand = "Select * from Employees"

selectcommand = "Select * from Employees"

connectionstring="Server=localhost;uid=sa;password=;database=northwind">

connectionstring="Server=localhost;uid=sa;password=;database=northwind">

</asp:sqldatasource>

Simple isnt it!!!! :-)

Simple isnt it!!!! :-)

Published Wednesday, March 24, 2004 9:01 PM by SushilaSB
Filed under:

Comments

Wednesday, March 24, 2004 10:47 PM by Jerry Pisk

# re: Using DetailsView in Whidbey

Simple indeed, who would want to bother to set password to system administrator user for their databases... Let alone run under a restricted security context, when running as the almighty sa with no password is so easy ;)

As for the control itself - I have to repeat what I keep saying - if it's simple it's not going to be any good. I don't seem to have much control over what's rendered, and while I understand that most mouse programmers don't care, it's nice to be able to control what's shown to the user, maybe logically group the data, show it as either a table or a list, be able to set styles and so on...
Wednesday, April 14, 2004 5:35 AM by Sachin

# re: Using DetailsView in Whidbey

Hi
Iam using detailsview control
want to add dropdownlist & textarea into
rowfield using template
Please tell me how to do it

Thanks
Wednesday, April 14, 2004 11:51 PM by Sushila

# re: Using DetailsView in Whidbey

You can write code as follows
<asp:detailsview id="DetailsView1" autogeneraterows =false datasourceid ="Sqldatasource1" runat="server">
<rowfields>
<asp:templatefield >
<itemtemplate >

<asp:textbox id="txt" runat =server textmode =multiLine text=<%#DataBinder.Eval(Container.DataItem, "notes")%> >

</asp:textbox>
</itemtemplate>
</asp:templatefield>
</rowfields>
</asp:detailsview>
Friday, April 16, 2004 6:35 AM by Ashok

# Using DetailsView in Whidbey

hi
I am using Gridview and DetailsView controls.I want to show hyperlink for each word(separated by ',') in single column of GridView and display related details in DetailsView when click on any link item.
How can I do it?

Thanks.
Monday, April 26, 2004 5:40 PM by JPaul

# re: Using DetailsView in Whidbey

Hi
I'm using Detailsview and i'm trying to insert a dropdownlist. I actually did it using a template (thanks for the previous posts) but it seems it doesn't work just like a boundfield. I mean, the selected value in the dropdownlist is not set according to the datasource. In fact, i don't see any way to link the template field to a datasource field.
Do you think i'm missing something? or maybe it simply doesn't work llike that....
thanks in advance.....
Saturday, May 01, 2004 6:40 AM by Sachin

# re: Using DetailsView in Whidbey

Hi,
How can I handle events of ListBox, added in Detailsview templatefield using c#,
e.g. I want to handle SelectedIndexChanged for listbox.

Thankx,
Regards,
Sachin
Thursday, May 06, 2004 12:50 AM by Sachin

# Prompt before deleting in detailsview

Hi,
I want to confirm whether user realy wants to delete the current row from detilsview, and
take action according to his click on YES/NO button.
How can I do this using C#.
Thankx.







































































































































































































































































































































































































































Thursday, May 06, 2004 3:08 PM by Sushila

# re: Using DetailsView in Whidbey

Leave a Comment

(required) 
(required) 
(optional)
(required)