Solved

gridview column is null asp.net 4.0

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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