ButtonColumn を DataTable (または、おそらく DataGrid) に追加する方法を理解するという奇妙な問題があります。私がやりたいのは、データテーブルのデータを使用してボタンにonClickで何かをするように指示できることだけですが、失敗しているようです。
それらはすべてItemTemplatesを使用しているため、Google検索ではすぐに役立つものは何も表示されませんでした.
//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[i]["UserInfoID"].ToString() + "); StoreUserInfoID(" + dt.Rows[i]["UserInfoID"].ToString() + "); ShowDiv();\">Ajax Link</button>";
dt.Rows[i]["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[i]["UserInfoID"].ToString();
newButton.Text = "Asp.Net Link";
newButton.Click += new EventHandler(Button_Link_Click);
dt.Rows[i]["Asp.Net Link"] = newButton; //@todo: Just a button to open a new window with the proper ID.
}
何か案は?