0

I have a function that is supposed to return ids of selected items from a list. It returns an expected value only when one file is selected. When you select multiple or none, it returns 0. I don't mind it returning 0 when nothing is selected, but how could I make it return a string of all ids when multiple files are selected? This is the function I'm using :

private int GetListItemIDFromQueryParameter()
{
    int result;
    Int32.TryParse(Request.QueryString["SPListItemId"], out result);
    return result;
}

If more code should be added, please let me know.

///

CommandAction="~remoteAppUrl/Pages/Default.aspx?{StandardTokens}&SPListItemId={SelectedItemId}&SPListId={SelectedListId}"

It returns a value of an item's ID if only one item is selected - if you select multiple, it returns 0, just as if you selected nothing.

  • Your question is not clear. Add your input url with querystring. – Anuja Aug 24 '17 at 9:17
  • Not quite sure if this is what you're asking for, but my best guess is this - (added in post after ///). Thank you for answering and if there is anything more I should provide, please let me know. – Qya Aug 24 '17 at 9:45
2

use the below code ( Tested and Working)

private ArrayList GetListItemIDFromQueryParameter()
    {

        string itemId;
        ArrayList listIds = new ArrayList();
        if (Request.QueryString.Get("SPListItemId") != null)
        {
            itemId = Request.QueryString.Get("SPListItemId");
            listIds.Add(itemId);
        }

        return listIds;
    }
  • Wow, I can't believe I haven't tried it. I just assumed it returned null when I got 0 int in both when I checked multiple files and checked nothing. Thank you very much! – Qya Aug 24 '17 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.