本文介绍了我们可以绑定gridview控件whcih在usercontrol中这样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 使用页作为 新页面() Dim userControl As UserControl = DirectCast (page.LoadControl( 〜/ UserControl / EICTEAMCOMMUNICATION.ascx ),UserControl) page.Controls.Add(userControl) Dim dtList 正如 DataTable = clsCommon.ListRecommendation(clsAuth.GetEXTMID) TryCast (userControl.FindControl( gridRecommend),GridView).DataSource = dtList TryCast (userControl.FindControl( gridRecommend),GridView).DataBind() page.Controls.Add(userControl) Dim writer As New StringWriter() page.Controls.Add (userControl) HttpContext.Current.Server.Execute(page,writer, False ) 返回 writer.ToString() 结束 使用 解决方案 Using page As New Page() Dim userControl As UserControl = DirectCast(page.LoadControl("~/UserControl/EICTEAMCOMMUNICATION.ascx"), UserControl) page.Controls.Add(userControl) Dim dtList As DataTable = clsCommon.ListRecommendation(clsAuth.GetEXTMID) TryCast(userControl.FindControl("gridRecommend"), GridView).DataSource = dtList TryCast(userControl.FindControl("gridRecommend"), GridView).DataBind() page.Controls.Add(userControl) Dim writer As New StringWriter() page.Controls.Add(userControl) HttpContext.Current.Server.Execute(page, writer, False) Return writer.ToString() End Using 解决方案 这篇关于我们可以绑定gridview控件whcih在usercontrol中这样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 22:38