在Detailsview中隐藏一行

在Detailsview中隐藏一行

本文介绍了在Detailsview中隐藏一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要隐藏详细信息视图的第一行,但详细信息视图有一个关键数据项,由另一部分代码读取。当我尝试进入ASP端并在行内选择visible = false时,后面的代码不再调用该数据。代码如下:

I need to hide the first row of a details view but the details view has a key dataitem which is read by another part of the code. when I try to go into the ASP side and select visible = false inside the row, the code behind no longer calls that data. the code is as follows:

<asp:detailsview ID="" runat="server" datakeynames="BICID">
     <fields>
          <asp:boundfield datafield="BICID" Headetertext="BICID"        

          SortExpression="BICID" Visible="false"/>
     </fields>





BICID是以下代码提取的关键数据项:





The BICID is the key data item that the following code is pulling:

protected void submitbttn_click(object sender, eventargs e)
{
     String bicidstring = detailsview1.rows[0].cells[1].text;
}





此代码在将行可见设置为false之前有效,无论如何都要隐藏该行和后面的代码还能工作吗?



This code worked before setting the row visible to false, is there anyway to hide that row and the code behind still work?

推荐答案


detailsview1.rows[0].visible = false;



或者


or

DetailsView1.Fields[1].Visible = false;



隐藏行,但在你之后再次已经获得了数据并将其放入一个全局变量中,以后可以在您的点击事件中使用。

我能想到的唯一另一种方法是让用户看不到该行使前景色和背景色相同。

还可以考虑使用


to hide the row, but again AFTER you've got the data and placed it into a global variable that can be later used in your click event.
The only other way I can think of is for you to make that row invisible to the user by making the forecolor and backcolor the same.
Also consider using

Style.Add("display","none");

我发现这个有时候有效当你不能使用Visible属性时。

I found this works sometimes when you cannot use the Visible property.


这篇关于在Detailsview中隐藏一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:18