Click here to Skip to main content
15,867,308 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionPdf to image converter Pin
Member 1501160216-Mar-21 20:42
Member 1501160216-Mar-21 20:42 
AnswerRe: Pdf to image converter Pin
Deepak Vasudevan22-Mar-21 3:13
Deepak Vasudevan22-Mar-21 3:13 
AnswerRe: Pdf to image converter Pin
Bohdan Stupak7-Apr-21 22:09
professionalBohdan Stupak7-Apr-21 22:09 
AnswerPlugins for api blog2.0 Pin
Member 1509734011-Mar-21 2:41
Member 1509734011-Mar-21 2:41 
GeneralRe: Plugins for api blog2.0 Pin
Deepak Vasudevan22-Mar-21 6:27
Deepak Vasudevan22-Mar-21 6:27 
QuestionHow do I install Winform NET 5 on Mac Pin
Member 150947959-Mar-21 16:24
Member 150947959-Mar-21 16:24 
AnswerFEED aggregator plugin Pin
Member 150933708-Mar-21 5:55
Member 150933708-Mar-21 5:55 
QuestionArgument out of range exception Pin
samflex17-Feb-21 18:38
samflex17-Feb-21 18: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 21:36
mveRichard MacCutchan17-Feb-21 21:36 
QuestionHow to Printing Network IP through MVC C# Pin
Member 150622761-Feb-21 20:32
Member 150622761-Feb-21 20:32 
AnswerRe: How to Printing Network IP through MVC C# Pin
Richard Deeming1-Feb-21 21:44
mveRichard Deeming1-Feb-21 21:44 
AnswerRe: How to Printing Network IP through MVC C# Pin
jkirkerx16-Feb-21 11:23
professionaljkirkerx16-Feb-21 11:23 
QuestionAngular NetCore 5 project and webpack 4.6 Pin
jkirkerx31-Jan-21 12:28
professionaljkirkerx31-Jan-21 12:28 
AnswerRe: Angular NetCore 5 project and webpack 4.6 [Pretty Close to Solving] Pin
jkirkerx1-Feb-21 6:21
professionaljkirkerx1-Feb-21 6:21 
QuestionGridView Not Refreshing after search function Executing. Pin
Darshan Kumar B25-Jan-21 1:30
Darshan Kumar B25-Jan-21 1:30 
AnswerRe: GridView Not Refreshing after search function Executing. Pin
20212a25-Jan-21 3:27
20212a25-Jan-21 3:27 
GeneralRe: GridView Not Refreshing after search function Executing. Pin
Darshan Kumar B26-Jan-21 17:18
Darshan Kumar B26-Jan-21 17:18 
GeneralRe: GridView Not Refreshing after search function Executing. Pin
20212a27-Jan-21 1:17
20212a27-Jan-21 1:17 
GeneralHow to distribute the processing load of one system on several systems؟ Pin
arminizadiankalantary24-Jan-21 20:18
arminizadiankalantary24-Jan-21 20:18 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Richard Deeming24-Jan-21 20:54
mveRichard Deeming24-Jan-21 20:54 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
arminizadiankalantary24-Jan-21 22:33
arminizadiankalantary24-Jan-21 22:33 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Richard Deeming24-Jan-21 22:39
mveRichard Deeming24-Jan-21 22:39 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
arminizadiankalantary24-Jan-21 23:38
arminizadiankalantary24-Jan-21 23:38 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Richard Deeming24-Jan-21 23:45
mveRichard Deeming24-Jan-21 23:45 
GeneralRe: How to distribute the processing load of one system on several systems؟ Pin
Nelek25-Jan-21 3:00
protectorNelek25-Jan-21 3: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.