Solved

gridview column is null asp.net 4.0

Posted on 2014-04-21
3
721 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
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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