在Detailsview中隐藏一行 [英] Hide a row in a Detailsview

查看:72
本文介绍了在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?

推荐答案

你可以尝试设置 InsertVisible =FalseReadOnly =True

这将在插入模式下隐藏项目,并且只在编辑模式下读取。
You can try setting InsertVisible="False" ReadOnly="True"
This will hide the item while in insert mode, and read only in edit mode.


这是正确的。一旦在DetailsView或任何其他View控件中设置了一行不可见或控件,该控件就不再对用户和后面的代码可见。那是你的ASP.net!

你必须以编程方式隐藏你在将数据加载到DetailsView之后的代码中的行。

我建议你放一个OnDataBound ()控制DetailsView并使用简单的

That's right. Once you have set a row invisible or a control inside a DetailsView or any other View control, that control is no longer visible to neither the user nor the code behind. That's ASP.net for you!
You have to programmatically hide the row in code behind AFTER you've loaded the data into the DetailsView.
I suggest you place an OnDataBound() control on the DetailsView and use a simple
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中隐藏一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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