By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

how to add 2 rows and 2 cols into datagrid

P: n/a
the first column title is "abc"
the second column title is 'efg'
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Bill
you might need to be more clear about what you want to do, also it differs
depending on whether if you are building web or windows application .
if you are using web here is how to add the columns
Here is an example so you can add columns of any types using many ways
<asp:datagrid DataKeyField="DiscId" id="DataGrid1" style="Z-INDEX: 110;
LEFT: 8px; POSITION: absolute; TOP: 408px"
runat="server" AutoGenerateColumns="False" CellPadding="8"
BorderWidth="2px" BorderColor="Yellow">
<HeaderStyle ForeColor="White" BackColor="Indigo"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="LabelText" HeaderText="DVD Content">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Color" HeaderText="Color">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="DiscImageFile" HeaderText="Image">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:ButtonColumn Text="Book" ButtonType="PushButton"
HeaderText="Reserve" CommandName="reserve">
<ItemStyle BackColor="Purple"></ItemStyle>
</asp:ButtonColumn>
<asp:TemplateColumn HeaderText="DVD View">
<ItemStyle BackColor="Purple"></ItemStyle>
<ItemTemplate>
<asp:Button runat="server" Text="Details" CommandName="opencontent"
CausesValidation="false"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
Note also that you can always use the method rows.add and coloumns.add
that add to the rows and columns collections respectively . you need to
define these rows or columns object before adding them however .

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.