DataGrid with buttons in rows

J

John Smith Jr.

I was wondering if this was possible, how does one place buttons or any
other control in a row of a datagrid (each row actually).

I even tried using DataGrid.Controls.Add() just to see where it would go
(column?) but i didn't see anything when I tried this.
 
R

rmkhan

Hi John

You can use template columns in dataGrid to add any control in row of datagrid

Syntax :

<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id=lblName runat="server" Text='<%# DataBinder.Eval
(Container, "DataItem.Name") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id=txtNameAdd runat="server" Text='<%# DataBinder.Eval
(Container, "DataItem.Name") %>'></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id=txtNameEdit runat="server" Text='<%#
DataBinder.EvalContainer, "DataItem.Name") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

Bye
Rehan Mustafa Khan
 
P

Paul

Take a look at the Columns collection in the Designer mode for the grid.
You can add template columns, or you can add Button columns, etc., which
will put controls on every row. In order to put bound controls into a
template column you will need to do a lot more reading on that subject.
Try 4GuysFromRolla who have put up a great series of articles on the
datagrid. Also, DataGridGirl has a website with lots of articles.

Button columns and EditCommand columns are easier to deal.
 
R

Rehan Mustafa Khan_MSFT

Hi John
You can use Template columns

----- John Smith Jr. wrote: -----

I was wondering if this was possible, how does one place buttons or any
other control in a row of a datagrid (each row actually).

I even tried using DataGrid.Controls.Add() just to see where it would go
(column?) but i didn't see anything when I tried this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top