Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with dynamic controls in datagrid?

Status
Not open for further replies.

Lbob

Programmer
May 23, 2003
157
0
0
GB
Hi

I want to add 2 buttons dynamically in the datagrid itemdatabound. I'm using the following code.

Private Sub dgData_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgData.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.SelectedItem Then

Dim i As Int16, x As Int16
For i = 0 To e.Item.Cells.Count - 1

btn.Text = "Cancel Visit"

btn.CommandName = "Cancel_click"

btn.EnableViewState = True

Next

My question is where & how do I then get the button to fire?

Cheers

Lbob
 
As they are dynamic controls, they will have to be created on every load of the page. You will also need to add the button to a parent control and associate an event handler with it e.g.






-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Thanks that works a treat!
Lbob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top