Hi,
If you want to use a button column, then you 've to write the eventhadler
for the button column you crfeated, separately.
Beofre that modify your .aspx source file like this, ( You have to include
OnItemCommand ).
<asp:DataGrid id="DgDetails" style="Z-INDEX: 103; LEFT: 64px; POSITION:
absolute; TOP: 168px"
runat="server" Width="784px" Height="120px" BorderColor="#3366CC"
BorderWidth="1px" BackColor="White"
BorderStyle="None" CellPadding="4" OnItemCommand="DgDetails_ItemCommand">
<SelectedItemStyle Font-Bold="True" ForeColor="#CCFF99"
BackColor="#009999"></SelectedItemStyle>
<ItemStyle ForeColor="#003399" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#CCCCFF"
BackColor="#003399"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select" DataTextField="DNo"></asp:ButtonColumn>
</Columns>
</asp:DataGrid>
You have to specify the index filed in "DataTextField" of <asp:ButtonColumn>
node.
In your code behind file...create a eventhandler as follows
void DgDetails_ItemCommand(Object sender, DataGridCommandEventArgs e)
{
Response.Write(e.Item.ItemIndex.ToString());
}
e.Item.ItemIndex will have the value you need.
Cheers,
Jerome. M
"Joana" wrote:
How do I make my ButtonColumn(In my DataGrid) to ResponseRedirect to another
aspx.page when the user click on the button. I also want send with a id for
the row.
For eksample:
************************************************** ****************
Private Sub DataGrid_kurs_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DataGrid_kurs.SelectedIndexChanged
Dim strKurs As String
strKurs = DataGrid_kurs.SelectedItem.Cells(0).Text
Response.Redirect("kurstilfelle.aspx?kurs=" + strKurs)
End Sub
******************************************
Is this the right plase to do it and how do make it work? Nothing happens
when I click on the button.
/Newbeginner :)