-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Swapnil_B1
Message 1 in Discussion

  
The Details View Control  
Many applications need to work on a single record at a time. In ASP.NET 1.x, 
there is no built-in support for this scenario. Creating a single record view 
is possible but requires some coding effort on your part. You have to fetch the 
record first, then bind its fields to a data-bound form, and optionally provide 
paging buttons to navigate between records. The need to display the contents of 
a single record is fairly common when you build master/detail views. Typically, 
the user selects a master record from a grid and the application drills down to 
show all the available fields. By combining GridView and DetailsView, you build 
hierarchical views with very little code.  
The DetailsView control can automatically bind to any data source control and 
take advantage of its set of data operations. The control can automatically 
page, update, insert, and delete data items in the underlying data source as 
long as the data source supports these operations. In most cases, no code is 
required to set up any of these operations, as shown here:  
<asp:detailsview runat="server" id="det"  
   datasourceid="MySource"  
   autogenerateeditbutton="true"  
   autogenerateinsertbutton="true"  
   autogeneratedeletebutton="true"  
   allowpaging="true"  
   headertext="Employees">  
   <pagersettings mode="NextPreviousFirstLast"  
      firstpageimageurl="images/first.gif"  
      lastpageimageurl="images/last.gif"  
      nextpageimageurl="images/next.gif"  
      previouspageimageurl="images/prev.gif" />  
</asp:detailsview>  
The user interface of the DetailsView control can be customized using data 
fields and styles in a way that is similar to the GridView. The DetailsView 
doesn't support custom templates as this specific capability has been entirely 
factored into the new FormView control. The DetailsView can have a command bar 
with any combination of Edit, Delete, and New buttons. When you click Edit or 
New, the control renders in Edit or Insert mode and the contents of fields are 
displayed in textboxes. The working mode can be controlled through the Mode and 
DefaultMode properties.  
The DetailsView control lends itself very well to implementing no-code 
master/details scenarios. Along with Edit and Delete buttons, the GridView 
control supports the Select button, which is also predefined. You enable this 
button on a per-row basis by setting the AutoGenerateSelectButton property to 
true. When the users click on this button, the current row enters the selected 
state and its zero-based index is assigned to the SelectedIndex property of the 
GridView. In addition, the GridView control raises the SelectedIndexChanged 
event. Applications can hook up to this event and run custom code.  
In ASP.NET 2.0 there's no need to handle the SelectedIndexChanged event if you 
want to build a master/detail view. You can drop a GridView and a DetailsView 
control on the page and bind each to a data source. The trick for codeless 
master/detail is to bind the detail control to a data source represented by the 
currently selected record, as shown in the following:  
<asp:sqldatasource runat="server" id="MyDetailSource:  
   selectcommand="SELECT * FROM customers"  
   filterexpression="customerid='@customerid'">  
   <filterparameters>  
     <asp:ControlParameter Name="customerid"  
        ControlId="masterGrid"  
        PropertyName="SelectedValue" />  
   </filterparameters>  
</asp:sqldatasource>  
The FilterExpression property of a data source object defines the WHERE clause 
for the base query specified by SelectCommand. Parameter values can be 
specified in a variety of ways, including through direct binding with a control 
property. The <ControlParameter> object sets the @customerid parameter to the 
value stored in the SelectedValue property of the master grid control.  
Swapnil (Swaps)  
http://swapsnet.spaces.live.com/

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to