Solved

gridview column is null asp.net 4.0

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now