本文介绍了回发后动态网格视图失去绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个动态网格视图,其中模板字段和绑定字段为列 第一页加载所有绑定看起来很好。所有列中都填充了值 当我触发一个事件,例如列标题中存在的下拉列表中更改的选定索引(内部模板字段)时,绑定将丢失,并且事件永远不会被捕获。 如何在发回邮件时保留控件以及如何解决这个问题? 这是我的代码
I have a dynamic grid View with template fields and bound fields as columns for the first page load all binding looks fine.values are populated in all columns when I trigger an event such as selected index changed in Drop downlist present in the column header(inside template field ) the binding are lost and the event is never catched. how to retain controls when post back occurs and how to resolve this problem ? this is my code
private void Subjectbind(string ExamYear, string ExamType) { if (ddlExamYear.SelectedIndex == 0) ExamYear = ddlExamYear.SelectedValue; if (ddlExamType.SelectedIndex == 0) ExamType = ddlExamType.SelectedValue; List lstCourses = objMDLClass.GetAllExamTypeCourses(Convert.ToInt32(ExamType), ExamYear); objManage = new StudentManage((Users)Session["user"]); foreach (SpGetExamTypeCourses_Result objCourse in lstCourses) { GridTemplateColumn col = new GridTemplateColumn(); col.UniqueName = objCourse.CourseId.ToString(); col.HeaderText = objCourse.CourseName; col.ItemTemplate = new GridCustomItemTemplate(objManage.GetExamAnalysisReport( Convert.ToInt32(objCourse.CourseId), Convert.ToInt32(ExamType), ExamYear)); gvSubwisePerformance.MasterTableView.Columns.Add(col); } gvSubwisePerformance.Rebind(); }推荐答案
仅当Page_Load不是回发时才绑定gridview上的gridview。 查看此内容: gridview在分页时丢失动态创建的模板列 [ ^ ] Bind the gridview on Page_Load only if it is not a postback. Check this out: gridview loses dynamically created template column when paging[^]
更多推荐
回发后动态网格视图失去绑定?
发布评论