Hi,
I am creating numerous dataviews dynamically and adding a buttonfield, however on click of the button the event handler rowcommand doesnt fire, can anyone help am i missing something.
The code is below
sqldatagrid.CommandText = SQLdr("sqlcommandtext") & " where id =" & Session("Id")
sqlreadergrid = sqldatagrid.ExecuteReader
Dg(counter1) = New GridView
Dg(counter1).ID = "dg" & counter1
Dg(counter1).DataSource = sqlreadergrid
ButtonColumn(counter1) = New ButtonField
ButtonColumn(counter1).CommandName = "ViewForm"
ButtonColumn(counter1).ButtonType = ButtonType.Button
ButtonColumn(counter1).HeaderText = "View Form"
ButtonColumn(counter1).Text = "Picture"
Dg(counter1).Columns.Add(ButtonColumn(counter1))
AddHandler Dg(counter1).RowCommand, AddressOf AllGridView_RowCommand
AddHandler Dg(counter1).RowCreated, AddressOf GridView1_RowCreated
Dg(counter1).DataBind()
Panelbody(counter1).Controls.Add(Dg(counter1))
Protected Sub AllGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim label2 As New Label
label2.Text = sender.ID
UpdatePanel1.ContentTemplateContainer.Controls.Add(label2)
End Sub
Thanks in advance
I am creating numerous dataviews dynamically and adding a buttonfield, however on click of the button the event handler rowcommand doesnt fire, can anyone help am i missing something.
The code is below
sqldatagrid.CommandText = SQLdr("sqlcommandtext") & " where id =" & Session("Id")
sqlreadergrid = sqldatagrid.ExecuteReader
Dg(counter1) = New GridView
Dg(counter1).ID = "dg" & counter1
Dg(counter1).DataSource = sqlreadergrid
ButtonColumn(counter1) = New ButtonField
ButtonColumn(counter1).CommandName = "ViewForm"
ButtonColumn(counter1).ButtonType = ButtonType.Button
ButtonColumn(counter1).HeaderText = "View Form"
ButtonColumn(counter1).Text = "Picture"
Dg(counter1).Columns.Add(ButtonColumn(counter1))
AddHandler Dg(counter1).RowCommand, AddressOf AllGridView_RowCommand
AddHandler Dg(counter1).RowCreated, AddressOf GridView1_RowCreated
Dg(counter1).DataBind()
Panelbody(counter1).Controls.Add(Dg(counter1))
Protected Sub AllGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim label2 As New Label
label2.Text = sender.ID
UpdatePanel1.ContentTemplateContainer.Controls.Add(label2)
End Sub
Thanks in advance