Click here to Skip to main content
15,845,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">
          <asp:boundfield datafield="BICID" Headetertext="BICID"        
          SortExpression="BICID" Visible="false"/>

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;

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

You can try setting InsertVisible="False" ReadOnly="True"
This will hide the item while in insert mode, and read only in edit mode.
Share this answer
Sean8084 14-Oct-11 0:03am    
but it doesn't need to be visible at all, and there is no insert or edit modes, there's a text box in the detailsview that I use for the update (along with a separate button for submit)
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 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;

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
I found this works sometimes when you cannot use the Visible property.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900