回发后动态网格视图失去绑定?

编程入门 行业动态 更新时间:2024-10-27 04:37:57
本文介绍了回发后动态网格视图失去绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个动态网格视图,其中模板字段和绑定字段为列 第一页加载所有绑定看起来很好。所有列中都填充了值 当我触发一个事件,例如列标题中存在的下拉列表中更改的选定索引(内部模板字段)时,绑定将丢失,并且事件永远不会被捕获。 如何在发回邮件时保留控件以及如何解决这个问题? 这是我的代码

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[^]

更多推荐

回发后动态网格视图失去绑定?

本文发布于:2023-10-12 20:46:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   视图   绑定   动态   回发后

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!