Solved

gridview column is null asp.net 4.0

Posted on 2014-04-21
3
728 Views
Last Modified: 2014-04-30
I have recently converted an asp.net web application to 4.0 from 2.0. There is one feature in gridview that has stopped working since then. The gridview is populated with all the available orders. The first column is "edit" and the second column is "delete". These two columns are displayed for each row if the order can be modified. the issue I am having is when "edit" is clicked on an order, it goes to a different panel where the order can be edited but upon clicking "back" button when it reloads the gridview, the delete and edit columns are hidden for the row that was edited. When that row is bound, the following error is thrown

Specified argument was out of the range of valid values.

I have attached the gridview and the databound code behind. Please advise.
gridview-EE.txt
DataBound-EE.txt
0
Comment
Question by:Angel02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:Utkarsh Kulkarni
ID: 40014196
This issue is, the control that you are looking in the code does not exits. This might be due to binding or the other event, where you have logic written to hide the action.

Modify the code as follows

If (e.Row.Cells(1).Controls.Count > 0) AndAlso (e.Row.Cells(1).Controls(0) IsNot Nothing) Then
[indent]Dim lnk As LinkButton = e.Row.Cells(1).Controls(0)[/indent]
[indent]lnk.OnClientClick = "if(!confirm('Do you want to delete this?')) return false;"[/indent]
End If

Open in new window

0
 

Author Comment

by:Angel02
ID: 40015091
The issue here is that e.Row.Cells(1).Controls(0) should be accessible. I am not sure why it is not. After i hit edit on a row and reload the page, the edit and delete columns for that row disappear and a new link "Update" appears in the first column.

How can I make sure edit and delete columns are visible and accessible when the gridview loads?
0
 
LVL 7

Accepted Solution

by:
Utkarsh Kulkarni earned 500 total points
ID: 40015124
This action of edit / delete disappears & update link shown, suggests that it is in template on same page/grid. If you are showing / loading popup for edit action, then take this out from template & put as Image button. (Same for Delete button). This can be managed & there by no update link shown.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question