Buttoncolums in a Datagrid
Hi all,
i have seruoius problems adding a buttoncolum to a datagrid programmatically.
I added a buttoncolum to the datagrid whitc simply selects the item. At this point i would like have fired the SelectedIndex-Event, but nothing happened !!!
This is my code:
Private Sub Page_Load (...
[omitted]
DataGrid1.DataSource = myDs
DataGrid1.DataMember = myDs.Tables(0).TableName.ToString
Dim colonna As New ButtonColumn()
colonna.ButtonType = ButtonColumnType.LinkButton
colonna.HeaderText = "Select"
colonna.Text = "Select"
colonna.CommandName = DataGrid1.SelectCommandName
colonna.DataTextField = myDs.Tables(0).Columns(0).ColumnName.ToString
colonna.DataTextFormatString = "Sel"
DataGrid1.Columns.AddAt(myDs.Tables(0).Columns.Cou nt, colonna)
DataGrid1.DataBind()
[omitted]
End Sub
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
Errlabel.Text = sender.SelectedItem.Cells.Item(0).Text
End Sub
Can anyone help me, please????
|