<FooterTemplate> <asp:TextBox ID="TextBoxSitealias" runat="server" AutopostBack="true" OnTextChanged="TextBoxSitealias_TextChanged"></asp:TextBox> <AJAXToolkit:autocompleteextender runat="server" ID="autocompleteextenderSitealias" targetcontrolID="TextBoxSitealias" servicemethod="GetSitealiasList" minimumprefixlength="2" completioninterval="1000" enablecaching="true" completionsetcount="12" /> </FooterTemplate>
这是我的GrIDvIEw中的FooterTemplate.
protected voID TextBoxSitealias_TextChanged(object sender,EventArgs e) { string query = @"select distinct (isnull([site_address1],'') +isnull([site_address2],'') +isnull([site_address3],'') +isnull([site_address4],'') +isnull([site_address5],'') ) as 'Site_adresse',city,country,[site_ID] as 'siteID' FROM [Henkel].[dbo].[tbl_Henkel_site_info_upload] WHERE site_ID = '" + ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSitealias")).Text + "'"; conn.open(); sqlCommand cmd = new sqlCommand(query,conn); sqlDataReader myReader = cmd.ExecuteReader(); Datatable mytable = new Datatable(); mytable.Load(myReader); conn.Close(); if (mytable.Rows.Count > 0) { ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSiteAddress")).Text = Convert.ToString(mytable.Rows[0]["Site_adresse"]); ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSiteCity")).Text = Convert.ToString(mytable.Rows[0]["city"]); ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSiteCountry")).Text = Convert.ToString(mytable.Rows[0]["country"]); ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxIBSSiteID")).Text = Convert.ToString(mytable.Rows[0]["siteID"]); } else { ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSiteAddress")).Text = ""; ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSiteCity")).Text = ""; ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxSiteCountry")).Text = ""; ((TextBox)GrIDVIEw1.FooterRow.FindControl("TextBoxIBSSiteID")).Text = ""; } }
这是在专用文本框失去焦点时应立即调用的函数.
我一直在许多论坛上寻找原因,但所有这些回复都表明文本框需要AutopostBack属性(我的有).
小通知:我有相同的项目(具有所有相同的功能,我们公司的另一笔交易,在该项目中它工作正常.我已将项目代码复制到新项目并更改所有查询连接字符串)
希望有人可以帮助我吗? 总结
以上是内存溢出为你收集整理的C# – TextBox TextChanged事件未触发全部内容,希望文章能够帮你解决C# – TextBox TextChanged事件未触发所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)