Sunday, December 28, 2008

Datagrid

•What tags do you need to add within the asp:datagrid tags to bind columns manually?

< asp:DataGrid id="dgCart" AutoGenerateColumns="False" CellPadding="4" Width="448px" runat="server" >

< Columns >
< asp:ButtonColumn HeaderText="SELECT" Text="SELECT" CommandName="select" >< /asp:ButtonColumn >
< asp:BoundColumn DataField="ProductId" HeaderText="Product ID" >< /asp:BoundColumn >
< asp:BoundColumn DataField="ProductName" HeaderText="Product Name" >< /asp:BoundColumn >
< asp:BoundColumn DataField="UnitPrice" HeaderText="UnitPrice" >< /asp:BoundColumn >
< /Columns >
< /asp:DataGrid >

What tag do you use to add a hyperlink column to the DataGrid?
< asp:HyperLinkColumn > </ asp:HyperLinkColumn>

How do you implement Paging in .Net?

The DataGrid provides the means to display a group of records from the data source (for example, the first 10), and then navigate to the "page" containing the next 10 records, and so on through the data.
Using Ado.Net we can explicit control over the number of records returned from the data source, as well as how much data is to be cached locally in the DataSet.
1.Using DataAdapter.fill method give the value of 'Maxrecords' parameter
(Note: - Don't use it because query will return all records but fill the dataset based on value of 'maxrecords' parameter).
2.For SQL server database, combines a WHERE clause and a ORDER BY clause with TOP predicate.
3.If Data does not change often just cache records locally in DataSet and just take some records from the DataSet to display.

No comments:

Post a Comment