ASP.NET -> Adding a ButtonColumn to a DataTable or DataGridView (Programmatically)

SigV

New Member
Having the odd problem figuring out how to add a ButtonColumn to a DataTable (or, arguably, the DataGrid). All I want to do is be able to use the data from the datatable to tell a button to do something onClick, and I seem to be failing at it. A google search did not show anything immediately useful, as they are all using ItemTemplates.\[code\]//dt.Columns.Add("Ajax Link", typeof(Literal));ButtonColumn newButtonColumn = new ButtonColumn();newButtonColumn.HeaderText = "Asp.Net Link";dt.Columns.Add(); // Doesn't want newButtonColumn.for (int i = 0; i < dt.Rows.Count; i++){ /* Literal newAjaxLink = new Literal(); newAjaxLink.Text = "Test";//"<button type=\"button\" onclick=\"AjaxButton_onClick(" + dt.Rows["UserInfoID"].ToString() + "); StoreUserInfoID(" + dt.Rows["UserInfoID"].ToString() + "); ShowDiv();\">Ajax Link</button>"; dt.Rows["Ajax Link"] = newAjaxLink; // @todo: HTML button that triggers an AJAX call for load the proper data into the fields. Also to make the DIV visible. */ Button newButton = new Button(); newButton.ID = dt.Rows["UserInfoID"].ToString(); newButton.Text = "Asp.Net Link"; newButton.Click += new EventHandler(Button_Link_Click); dt.Rows["Asp.Net Link"] = newButton; //@todo: Just a button to open a new window with the proper ID.}\[/code\]Any ideas?
 
Back
Top