I have a page that is devided into 3 <div>'s TopNav, LeftNav & Content. In the content div I have a placerholder control. Programatically I create a datagrid that gets placed into that placeholder. The code looks like this;
private sub GetPhotoList()
...some code here that creates the grid columns then
'bind datagrid
SqldaPhotos.SelectCommand.Parameters("@Param2").Value = CInt(txtMemberID.Text)
SqldaPhotos.Fill(DsPhotos1)
DataGrid1.DataSource = DsPhotos1
DataGrid1.DataMember = "Photos"
DataGrid1.DataKeyField = "PK_ID"
DataGrid1.DataBind()
'add datagrid to the page
PlaceHolder1.Controls.Add(DataGrid1)
PlaceHolder1.ID = "Placeholder1"
DataGrid1.ID = "Datagrid1"
'add event handlers
AddHandler DataGrid1.ItemCommand, AddressOf DataGrid1_ItemCommand
end sub
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
Dim iRow As Integer
iRow = CInt(e.Item.Cells(4).Text)
Dim sPictureName = e.Item.Cells(5).Text
ShowPicture(iRow, sPictureName)
End Sub
The the datagrid contains a
linkbutton column but I can not seen to grab the itemcommand event when the button is clicked on the page. The grid works if I do not place it into the placeholder, but then I can not position it properly on the page. Any one have suggestions?
mcantellay
Member
10 Points
2 Posts
Can not grab event when Datagrid is inside a placeholder
Aug 22, 2003 07:15 PM|LINK
private sub GetPhotoList() ...some code here that creates the grid columns then 'bind datagrid SqldaPhotos.SelectCommand.Parameters("@Param2").Value = CInt(txtMemberID.Text) SqldaPhotos.Fill(DsPhotos1) DataGrid1.DataSource = DsPhotos1 DataGrid1.DataMember = "Photos" DataGrid1.DataKeyField = "PK_ID" DataGrid1.DataBind() 'add datagrid to the page PlaceHolder1.Controls.Add(DataGrid1) PlaceHolder1.ID = "Placeholder1" DataGrid1.ID = "Datagrid1" 'add event handlers AddHandler DataGrid1.ItemCommand, AddressOf DataGrid1_ItemCommand end sub Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand Dim iRow As Integer iRow = CInt(e.Item.Cells(4).Text) Dim sPictureName = e.Item.Cells(5).Text ShowPicture(iRow, sPictureName) End SubThe the datagrid contains a linkbutton column but I can not seen to grab the itemcommand event when the button is clicked on the page. The grid works if I do not place it into the placeholder, but then I can not position it properly on the page. Any one have suggestions?