无法在单个页面上呈现两个gridviews [英] cannot render two gridviews on a single page

查看:81
本文介绍了无法在单个页面上呈现两个gridviews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在页面上重复使用两次以在同一页面上呈现两个不同的网格视图,并且可以很好地帮助我或任何想法.



I cannot seam to use this twice on my page to render two different gridviews on the same page works well with one can any help me or any ideas would be appreciated



protected override void Render(System.Web.UI.HtmlTextWriter writer)
       {

               foreach (GridViewRow row in gdvauthors.Rows)
               {
                   if (row.RowType == DataControlRowType.DataRow)
                   {
                       row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
                       row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
                       // Set the last parameter to True
                       // to register for event validation.
                       row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(gdvauthors, "Select$" + row.DataItemIndex, true);
                   }
               }
               base.Render(writer);


       }

推荐答案

" + row.DataItemIndex,基本 .Render(writer); }
" + row.DataItemIndex, true); } } base.Render(writer); }


您只需要做一些重构,然后就可以使用相同的代码来呈现不同的GridViews

You just need to do a bit of refactoring, then you can use the same code to render different GridViews

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
       this.RenderGridView(gdvauthors);
       this.RenderGridView(otherGridView);         
       base.Render(writer);
}

private void RenderGridView(GridView gridView)
{
 foreach (GridViewRow row in gridView.Rows)
       {
           if (row.RowType == DataControlRowType.DataRow)
           {
               row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
               row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
               // Set the last parameter to True
               // to register for event validation.
               row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(gdvauthors, "Select


" + row.DataItemIndex,
" + row.DataItemIndex, true); } } }


这篇关于无法在单个页面上呈现两个gridviews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆