Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

gridview column is null asp.net 4.0

Posted on 2014-04-21
3
Medium Priority
?
738 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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