弹出gridview链接按钮
本文关键字:按钮 链接 gridview 弹出 | 更新日期: 2023-09-27 17:53:21
这是aspx页面代码
"OnClick = " lnkCustomer ">"SelectCommand="SELECT DISTINCT [firstname], [middle lename], [lastname], [mobile], [city], [title], [enquirymasterid] FROM [EnquiryMaster]">*我在gridview的链接按钮后面写了这个代码,但是弹出窗口不显示*w
protected void lnkCustomer(object sender, EventArgs e)
{
//Retrieve Customer ID
LinkButton lnkCustomerID = sender as LinkButton;
string strCustomerID = lnkCustomerID.Text;
//Create sql connection and fetch data from database based on CustomerID
string strConnectionString = ConfigurationManager.ConnectionStrings["connstring"].ConnectionString;
string strSelect = "SELECT DISTINCT [firstname], [middlename], [lastname], [mobile], [city], [title], [enquirymasterid] FROM [EnquiryMaster] WHERE enquirymasterid = @enquirymasterid";
SqlConnection sqlCon = new SqlConnection();
sqlCon.ConnectionString = strConnectionString;
SqlCommand cmdCustomerDetails = new SqlCommand();
cmdCustomerDetails.Connection = sqlCon;
cmdCustomerDetails.CommandType = System.Data.CommandType.Text;
cmdCustomerDetails.CommandText = strSelect;
cmdCustomerDetails.Parameters.AddWithValue("@enquirymasterid", strCustomerID);
sqlCon.Open();
//Create DataReader to read the record
SqlDataReader dReader = cmdCustomerDetails.ExecuteReader();
GridView2.DataSource = dReader;
GridView2.DataBind();
sqlCon.Close();
modalPopUpExtender1.Show();
}
呼叫按钮应该在更新面板中,阅读这篇博文(你可能想要考虑不使用ajaxcontroltoolkit,并切换到基于jquery的解决方案)