Click here to Skip to main content
15,510,280 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionPdf to image converter Pin
Member 1501160216-Mar-21 21:42
Member 1501160216-Mar-21 21:42 
AnswerRe: Pdf to image converter Pin
Deepak Vasudevan22-Mar-21 4:13
Deepak Vasudevan22-Mar-21 4:13 
AnswerRe: Pdf to image converter Pin
Bohdan Stupak7-Apr-21 23:09
professionalBohdan Stupak7-Apr-21 23:09 
AnswerPlugins for api blog2.0 Pin
Member 1509734011-Mar-21 3:41
Member 1509734011-Mar-21 3:41 
GeneralRe: Plugins for api blog2.0 Pin
Deepak Vasudevan22-Mar-21 7:27
Deepak Vasudevan22-Mar-21 7:27 
QuestionHow do I install Winform NET 5 on Mac Pin
Member 150947959-Mar-21 17:24
Member 150947959-Mar-21 17:24 
AnswerFEED aggregator plugin Pin
Member 150933708-Mar-21 6:55
Member 150933708-Mar-21 6:55 
QuestionArgument out of range exception Pin
samflex17-Feb-21 19:38
samflex17-Feb-21 19:38 
Greetings experts,

I am incredibly frustrated by this task. We have a sorting feature added to our GridView control which works great.

Then we decided to adding sorting up and down arrow and that's when we started having issues.

I have been working on this now for three days and can't seem to get anywhere with it.

I really do need some help.

When we run our code, we get keep getting the following error:

System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values.
Parameter name: index'


The error is on this line:
string lbText = ((LinkButton)grvSpeakers.HeaderRow.Cells[i].Controls[0]).Text;


I believe this is the relevant code:

C#
protected void OnSorting(object sender, GridViewSortEventArgs e)
{
    string SortDir = string.Empty;
    DataTable dt = new DataTable();
    dt = ViewState["tables"] as DataTable;
    {
        if (SortDirection == SortDirection.Ascending)
        {
            SortDirection = SortDirection.Descending;
            SortDir = "Desc";
        }
        else
        {
            SortDirection = SortDirection.Ascending;
            SortDir = "Asc";
        }
        DataView sortedView = new DataView(dt);
        sortedView.Sort = string.Format("{0} {1}", e.SortExpression, SortDir);
        grvSpeakers.DataSource = sortedView;
        grvSpeakers.DataBind();
        for (int i = 0; i < grvSpeakers.Columns.Count; i++)
        {
            string lbText = ((LinkButton)grvSpeakers.HeaderRow.Cells[i].Controls[0]).Text;
            if (lbText == e.SortExpression)
            {
                TableCell tableCell = grvSpeakers.HeaderRow.Cells[i];
                System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
                img.ImageUrl = (SortDir == "Asc") ? "~/Images/down_arrow.png" : "~/Images/up_arrow.png";
                tableCell.Controls.Add(new LiteralControl(" "));
                tableCell.Controls.Add(img);
            }
        }
    }
}


Please forgive me for the code dump. I am hoping it helps show what I could be doing wrong.

The GridView has 6 header columns with SortExpressions, Speaker Name, Ministry Name, Email, Date Added, Client Name and website URL

Each has a sortExpress like
SortExpression="SpeakerName"
for instance.

Any assistance is greatly appreciated.

Many thanks in advance
AnswerRe: Argument out of range exception Pin
Richard MacCutchan17-Feb-21 22:36
mveRichard MacCutchan17-Feb-21 22:36 
QuestionHow to Printing Network IP through MVC C# Pin
Member 150622761-Feb-21 21:32
Member 150622761-Feb-21 21:32 
AnswerRe: How to Printing Network IP through MVC C# Pin
Richard Deeming1-Feb-21 22:44
mveRichard Deeming1-Feb-21 22:44 
AnswerRe: How to Printing Network IP through MVC C# Pin
jkirkerx16-Feb-21 12:23
professionaljkirkerx16-Feb-21 12:23 
QuestionAngular NetCore 5 project and webpack 4.6 Pin
jkirkerx31-Jan-21 13:28
professionaljkirkerx31-Jan-21 13:28 
AnswerRe: Angular NetCore 5 project and webpack 4.6 [Pretty Close to Solving] Pin
jkirkerx1-Feb-21 7:21
professionaljkirkerx1-Feb-21 7:21 
QuestionGridView Not Refreshing after search function Executing. Pin
Darshan Kumar B25-Jan-21 2:30
Darshan Kumar B25-Jan-21 2:30 
AnswerRe: GridView Not Refreshing after search function Executing. Pin
20212a25-Jan-21 4:27
20212a25-Jan-21 4:27 
GeneralRe: GridView Not Refreshing after search function Executing. Pin
Darshan Kumar B26-Jan-21 18:18
Darshan Kumar B26-Jan-21 18:18 
GeneralRe: GridView Not Refreshing after search function Executing. Pin
20212a27-Jan-21 2:17
20212a27-Jan-21 2:17 
GeneralHow to distribute the processing load of one system on several systems؟ Pin
arminizadiankalantary24-Jan-21 21:18
arminizadiankalantary24-Jan-21 21:18 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Richard Deeming24-Jan-21 21:54
mveRichard Deeming24-Jan-21 21:54 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
arminizadiankalantary24-Jan-21 23:33
arminizadiankalantary24-Jan-21 23:33 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Richard Deeming24-Jan-21 23:39
mveRichard Deeming24-Jan-21 23:39 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
arminizadiankalantary25-Jan-21 0:38
arminizadiankalantary25-Jan-21 0:38 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Richard Deeming25-Jan-21 0:45
mveRichard Deeming25-Jan-21 0:45 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Nelek25-Jan-21 4:00
protectorNelek25-Jan-21 4:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.