How to set ellipses on a column data if it exceeds more than a set record

后端 未结 2 387
清酒与你
清酒与你 2021-01-07 08:24

How to set ellipses on a column data

I have the following BoundField in my GridView:



        
2条回答
  •  有刺的猬
    2021-01-07 08:56

    You seem to be modifying this where you could not store it back to the database anyway so I would just handle it like this unless they need an option to then see the entirety of the data.

    I did all this c# in this editor so there might be slight problems, lets call it psuedo code!

    string provider = item["Provider"].ToString().Replace("#", "\n").TrimStart(';');
    string[] providerListing = provider.Split(new[]{";"}, StringSplitOptions.RemoveEmptyEntries));
    if(providerListing.Length > 3)
    {
        //Make an array of the first 3 providers
        string[] firstProviders = new string[3];
        Array.Copy(providerListing, firstProviders, 3);
        //Reconcatenate with ; and add ellipsis
        provider = String.Join(";",firstProviders)+"...";
    }
    

    If they do need to see the entirety of the data I would add another column called FullProviders or something like that to query.

提交回复
热议问题