Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Gridview -  Index was out of range.

Posted on 2009-05-11
4
Medium Priority
?
365 Views
Last Modified: 2012-05-06
I have a gridview which I have populated using

Gridview1.DataSource = DataSet1;
Gridview1.databind();

when I run the following code

Gridview.Columns[4].ItemStyle.Width = 100;

I get an error saying Index was out of range.

I just don't understand as column 4 exists.
0
Comment
Question by:Mr_Shaw
[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
4 Comments
 
LVL 7

Accepted Solution

by:
Chandan_Gowda earned 500 total points
ID: 24352634
1) First find how many columns you have in the grid (Gridview.Columns.count)
2)analyze the column index thru immediate window of VS.Net.
0
 
LVL 9

Assisted Solution

by:Deathrace
Deathrace earned 500 total points
ID: 24352650
hey,
try chaning the index value to 3 , if you have 4 columns in your Grid, that might be the cause.
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31580066
thanks
0
 

Author Comment

by:Mr_Shaw
ID: 24352762
the code which worked was

 if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[4].Width = 500;
        }
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 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