动态创建的DataTable ,然后又动态添加了列,再怎么在列中动态添加LinkButton
Dimnewcoun1AsData.DataColumn=NewData.DataColumn()DimnewlbtnAsLinkButton=NewLinkButton...
Dim newcoun1 As Data.DataColumn = New Data.DataColumn()
Dim newlbtn As LinkButton = New LinkButton()
怎么在newcoun1 列的下面添加LinkButton 展开
Dim newlbtn As LinkButton = New LinkButton()
怎么在newcoun1 列的下面添加LinkButton 展开
1个回答
展开全部
你确定不是添加数据后把linkbutton绑定到页面?
///创建DataTable对象
DataTable dataTable = new DataTable();
///添加新的数据列
dataTable.Columns.Add("ID",typeof(int));
dataTable.Columns.Add("Username",typeof(string));
dataTable.Columns.Add("Email",typeof(string));
dataTable.Columns.Add("RoleID",typeof(int));
dataTable.Columns.Add("RoleName",typeof(string));
dataTable.Columns.Add("CreateDate",typeof(DateTime));
dataTable.Columns.Add("Address",typeof(string));
while(dr.Read())
{ ///添加新的数据行
DataRow row = dataTable.NewRow();
row["ID"] = dr["ID"].ToString();
row["Username"] = dr["Username"].ToString();
row["Email"] = dr["Email"].ToString();
row["RoleID"] = dr["RoleID"].ToString();
row["RoleName"] = dr["RoleName"].ToString();
row["CreateDate"] = dr["CreateDate"].ToString();
row["Address"] = dr["Address"].ToString();
dataTable.Rows.Add(row);
}
在前台绑定这个表格的时候绑定个linkbutton就行了
比如:……………………
………………………………
………………………………
<td>
<linkbutton>aaaaa</linkbutton> </td>
</tr>
</ItemTemplate>
</asp:Repeater>
///创建DataTable对象
DataTable dataTable = new DataTable();
///添加新的数据列
dataTable.Columns.Add("ID",typeof(int));
dataTable.Columns.Add("Username",typeof(string));
dataTable.Columns.Add("Email",typeof(string));
dataTable.Columns.Add("RoleID",typeof(int));
dataTable.Columns.Add("RoleName",typeof(string));
dataTable.Columns.Add("CreateDate",typeof(DateTime));
dataTable.Columns.Add("Address",typeof(string));
while(dr.Read())
{ ///添加新的数据行
DataRow row = dataTable.NewRow();
row["ID"] = dr["ID"].ToString();
row["Username"] = dr["Username"].ToString();
row["Email"] = dr["Email"].ToString();
row["RoleID"] = dr["RoleID"].ToString();
row["RoleName"] = dr["RoleName"].ToString();
row["CreateDate"] = dr["CreateDate"].ToString();
row["Address"] = dr["Address"].ToString();
dataTable.Rows.Add(row);
}
在前台绑定这个表格的时候绑定个linkbutton就行了
比如:……………………
………………………………
………………………………
<td>
<linkbutton>aaaaa</linkbutton> </td>
</tr>
</ItemTemplate>
</asp:Repeater>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询