c# datalist 问题

2024-12-26 00:05:16
推荐回答(3个)
回答1:



'
runat="server" OnClick="LinkButton1_Click">LinkButton





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

protected void LinkButton1_Click(object sender, EventArgs e)
{
LinkButton lkbtn = sender as LinkButton;
string strsql = "SELECT * FROM Tablename where 字段名='" + lkbtn.CommandArgument.ToString() + "'";//查询的列名为前台模版列LinkButton CommandArgument属性绑定的字段;
DataTable tbl = new DataTable();
///根据Sql语句获取Datatable
DataList2.DataSource = tbl;
DataList2.DataBind();
}

用DataList的事件也可以

回答2:

把datalist2的绑定写在datalist1_SelectedIndexChanged(object sender, EventArgs e)中

回答3:

传个你