What is the syntax for datagrid and specifying columns ?
Answers were Sorted based on User's Feedback
Answer / dagam
<asp:GridView ID="GridView1" runat="server" Width="335px">
<Columns>
</Columns>
</asp:GridView>
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / venugopal
The DataGrid is a Web server control that is used for data
display. This control provides the easy way to bind the
data from the database to the user in a user-friendly
manner. The DataGrid control renders a tabular, data-bound
grid. The DataGrid control displays the fields of a data
source as columns in a table. Each row in the DataGrid
control represents a record in the data source. The
DataGrid control supports selection, editing, deleting,
paging, and sorting.
The datagrid has the following column types:
EditCommandColumn : Encapsulates the most common edit
commands (Edit, Update, Cancel) in a predefined column
type.
HyperLinkColumn : Creates a column with a set of
hyperlinks that are bound to the value of a data field. For
example, a grid that displays a list of orders can include
a hyperlink column where the OrderID field is rendered as a
hyperlink to a page that displays the details for the
order.
BoundColumn :Creates column bound to a field in the
data source and rendered in a table cell using styles. This
is the default column type for the DataGrid control.
BottonColumn : Creates a column that contains a user
defined command button, such as Add or Remove, for each
item in the column.
TemplateColumn : Creates a column that allows you to
define the layout of controls using templates for custom
HTML elements and controls.
The syntax for the datagrid and columns is as fallows
<asp:datagrid id="dgPopularFAQs" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="FAQID" ItemStyle-
Width="10%"
ItemStyle-HorizontalAlign="Center"
HeaderText="FAQ ID" />
<asp:TemplateColumn HeaderText="FAQ Information">
<ItemTemplate>
<table border="0">
<tr>
<td align="right"><b>Description:</b></td>
<td><%# DataBinder.Eval
(Container.DataItem, "Description") %></td>
</tr>
<tr>
<td align="right"><b>Category Name:</b></td>
<td><%# DataBinder.Eval
(Container.DataItem, "CatName") %></td>
</tr>
<tr>
<td align="right"><b>View Count:</b></td>
<td><%# DataBinder.Eval
(Container.DataItem, "ViewCount", "{0:#,###}") %>
</td>
</tr>
</table>
</ItemTemplate>
</Columns>
</asp:datagrid>
Is This Answer Correct ? | 4 Yes | 0 No |
Differentiate between a hyperlink control and a linkbutton control.
What is shared and private assembly?
what is the differance between .DLL & .EXE
10 Answers Infinite Computer Solutions,
Using Statement usage in C#
What is asp net application object?
i need code for insert,delete,update adn display records using stored procedure in C#
when will garbage collector run?
When you are running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?
What is session and application variable in asp net?
What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState ?
Advantage of data Reader?
Hi, I am a fresher. i have a problem related to DataGrid . i have a data grid and i have to place a dropdown in the datagrid.and i have to retrieve the values from the database (sqlserver).please tell me any idea about the code.