How can I make an asp.net 2003 datagrid that has 6 columns (apart from the columns of the data) link in each of them, and what I am more lost: As a process each of the events of each link ? Thanks.
How can I make an asp.net 2003 datagrid that has 6 columns (apart from the columns of the data) link in each of them, and what I am more lost: As a process each of the events of each link ? Thanks.
To create additional columns you should only define them in the design
Creating Custom Columns for the ASP.NET Datagrid
I imagine in your grid you define the property AutoGenerateColumns
in true. As you will notice in the article there are several ways to achieve it
You could define a columns of type HyperLinkColumn
<asp:DataGrid id="DataGrid1"
runat="server"
AutoGenerateColumns="true">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="application_id"
DataNavigateUrlFormatString="applicationform.aspx?id={0}"
DataTextField="application_id" HeaderText="APPLICATION_ID"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>
In this case it would be a link in the column that redirects to a url, the property DataNavigateUrlField
Another alternative would be using <asp:ButtonColumn>
.
<asp:DataGrid id="DataGrid1"
runat="server"
AutoGenerateColumns="true">
<Columns>
<asp:ButtonColumn
HeaderText="Edit item"
ButtonType="LinkButton"
Text="Edit"
CommandName="Edit"/>
</Columns>
</asp:DataGrid>
You can define several ButtonColumn as you need
The action is received in the event ItemCommand where you will have the CommandName
to know what action was hit
Just what I would advise is that if you want to give a specific position to these columns you define them all in design time and assign the AutoGenerateColumns="false"