D
Dude
I add a link button to the header of my datagrid as follows:
If e.Item.ItemType = ListItemType.Header Then
Dim myLink As New LinkButton()
myLink.Text = "Add New"
myLink.Attributes.Add("runat", "server")
myLink.Attributes.Add("id", "btnAddNew")
myLink.Attributes.Add("CommandName", "btnAddNew")
myLink.Attributes.Add("CommandArgument", "btnAddNew")
e.Item.Cells(2).Controls.Add(myLink)
AddHandler myLink.Click, AddressOf Me.btnAddNew_Click
End If
After postback the sub, btnAddNew_Click is not called. I assume this
is because since the control is created programatically, it needs to
be recreated on postback by the page_onload. However, at page_onload
the datagrid is not yet created, so how can I create the LinkButton
and add it?
Thanks!
If e.Item.ItemType = ListItemType.Header Then
Dim myLink As New LinkButton()
myLink.Text = "Add New"
myLink.Attributes.Add("runat", "server")
myLink.Attributes.Add("id", "btnAddNew")
myLink.Attributes.Add("CommandName", "btnAddNew")
myLink.Attributes.Add("CommandArgument", "btnAddNew")
e.Item.Cells(2).Controls.Add(myLink)
AddHandler myLink.Click, AddressOf Me.btnAddNew_Click
End If
After postback the sub, btnAddNew_Click is not called. I assume this
is because since the control is created programatically, it needs to
be recreated on postback by the page_onload. However, at page_onload
the datagrid is not yet created, so how can I create the LinkButton
and add it?
Thanks!