最近开始用asp.net来开发一个网站,其中用到了gridview控件.要实现根据不同的查询方式,使gridview绑定到不同的存储过程中,能动态的改变gridview列的个数,并添加一列 ButtonField.
但是在给 ButtonField中的button动态绑定事件的时候出现问题,事件根本绑定不上.
希望各位仁兄为小弟我解决一下这个问题啊
代码如下(下面只是实现按拼音方式查询时的数据绑定)
public partial class SearchResult : System.Web.UI.Page
... {
protected void Page_Load(object sender, EventArgs e)
...{
if (!IsPostBack)
...{
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet dataset = new DataSet();
SqlCommand command = new SqlCommand();
string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
using (SqlConnection connection = new SqlConnection(constr))
...{
command.CommandText = "按拼音姓名查询";
command.CommandType = CommandType.StoredProcedure;