Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 778775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:49:11+00:00 2026-05-14T19:49:11+00:00

I am binding some data to control, but want to limit the number of

  • 0

I am binding some data to control, but want to limit the number of character of a specific field to a 30 first characters.

I want to do it, if it’s possible, on aspx page.

I tried this:

Text='<%# String.Format("{0}", Eval("Title")).Substring(0,30) %> '

But got this error:

Index and length must refer to a
location within the string. Parameter
name: length

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:49:12+00:00Added an answer on May 14, 2026 at 7:49 pm

    As Simon says, you’ll encounter this error when the string is less than 30 characters.

    You can write a protected method in your page –

    protected string GetSubstring(string str, int length)
    {
        return str.Length > length ? str.Substring(0, length) : str;
    }
    

    Call it from the aspx code like this –

    Text='<%# String.Format("{0}", GetSubstring(Eval("Title").ToString(), 30) %>'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement some very simple Data Binding in my User Control
There are some posts discussing adding data-binding ability for ListView.SelectedItems with non-trivial amount of
I was wondering about some best practices for data binding in web forms. For
Where can I find some good documentation on data/element binding? My Google searches haven't
I want to be able to add a Binding to some properties of a
I have a UserControl that I want to participate in data binding. I've set
I'm working on a project where I have some hierarchical data that I want
Now I've seen some questions like this, but it's not exactly what I want
I want to visualize some data in my Windows Phone app. So I'm using
I want brief knowledge about Data Template for Customizing a control(like Combo Box,List Box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.