Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. about substring

about substring

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdatabasequestion
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Rajeshwar Code Developer

    hai i have one doubt i m using substring in for to display only 10 characters i m fetching data from database.. column name called description and now i want to substring of that desciption colunm , write code in c#. and i wrote code for that like this lbl_sub.Text = lbl_sub.Text.Substring(0,5-0).ToString() + ".."; this coding working but my problem is when i m fetching .. if there is no data in database ..the n i m getting error. if data lessthan 5 characters then also i m getting error.. plz could u tell me how can i do this ..

    try and try untill reach success..

    A Offline
    A Offline
    Arun Jacob
    wrote on last edited by
    #2

    try this,

    if(!string.IsNullOrEmpty(lbl_sub.Text))
    {
    lbl_sub.Text = (lbl_sub.Text.Length > 5) ? lbl_sub.Text.Substring(0, 5) : lbl_sub.Text;
    }

    Arun Jacob http://codepronet.blogspot.com/

    R 1 Reply Last reply
    0
    • A Arun Jacob

      try this,

      if(!string.IsNullOrEmpty(lbl_sub.Text))
      {
      lbl_sub.Text = (lbl_sub.Text.Length > 5) ? lbl_sub.Text.Substring(0, 5) : lbl_sub.Text;
      }

      Arun Jacob http://codepronet.blogspot.com/

      R Offline
      R Offline
      Rajeshwar Code Developer
      wrote on last edited by
      #3

      Thanks dude its working ..thanks a lot .. do u know how can i change color of that description column data nad disply into different color.

      try and try untill reach success..

      A 2 Replies Last reply
      0
      • R Rajeshwar Code Developer

        Thanks dude its working ..thanks a lot .. do u know how can i change color of that description column data nad disply into different color.

        try and try untill reach success..

        A Offline
        A Offline
        Arun Jacob
        wrote on last edited by
        #4

        :thumbsup:

        Arun Jacob http://codepronet.blogspot.com/

        1 Reply Last reply
        0
        • R Rajeshwar Code Developer

          Thanks dude its working ..thanks a lot .. do u know how can i change color of that description column data nad disply into different color.

          try and try untill reach success..

          A Offline
          A Offline
          Arun Jacob
          wrote on last edited by
          #5

          Rajeshwar Code- Developer wrote:

          do u know how can i change color of that description column data nad disply into different color.

          You are displaying it in a label.right? Then just give color for label. :)

          Arun Jacob http://codepronet.blogspot.com/

          R 1 Reply Last reply
          0
          • R Rajeshwar Code Developer

            no no i m not displaying in label ..just that is for ex.. actaully how can i substring for dataset. i m displaying in treeview.

            try and try untill reach success..

            A Offline
            A Offline
            Arun Jacob
            wrote on last edited by
            #6

            If you are using treeview you can do it while adding the nodes to treeview. :)

            Arun Jacob http://codepronet.blogspot.com/

            R 1 Reply Last reply
            0
            • A Arun Jacob

              Rajeshwar Code- Developer wrote:

              do u know how can i change color of that description column data nad disply into different color.

              You are displaying it in a label.right? Then just give color for label. :)

              Arun Jacob http://codepronet.blogspot.com/

              R Offline
              R Offline
              Rajeshwar Code Developer
              wrote on last edited by
              #7

              no no i m not displaying in label ..just that is for ex.. actaully how can i substring for dataset. i m displaying in treeview.

              try and try untill reach success..

              A 1 Reply Last reply
              0
              • A Arun Jacob

                If you are using treeview you can do it while adding the nodes to treeview. :)

                Arun Jacob http://codepronet.blogspot.com/

                R Offline
                R Offline
                Rajeshwar Code Developer
                wrote on last edited by
                #8

                i enable to unserstand how can i so it.. only just tell me .. ds.tables[0].rows[0]["desc"].tostring; i fetch data from database now my desc column data it is in ds ..right plzz could u tell me how can i do substring and change the color..

                try and try untill reach success..

                A 1 Reply Last reply
                0
                • R Rajeshwar Code Developer

                  i enable to unserstand how can i so it.. only just tell me .. ds.tables[0].rows[0]["desc"].tostring; i fetch data from database now my desc column data it is in ds ..right plzz could u tell me how can i do substring and change the color..

                  try and try untill reach success..

                  A Offline
                  A Offline
                  Arun Jacob
                  wrote on last edited by
                  #9

                  Where you want to display that description.As treeview node? You have multiple rows.Where you want to change the color?because every node having description.

                  Arun Jacob http://codepronet.blogspot.com/

                  R 1 Reply Last reply
                  0
                  • A Arun Jacob

                    Where you want to display that description.As treeview node? You have multiple rows.Where you want to change the color?because every node having description.

                    Arun Jacob http://codepronet.blogspot.com/

                    R Offline
                    R Offline
                    Rajeshwar Code Developer
                    wrote on last edited by
                    #10

                    yes i want to change every row of the description...

                    try and try untill reach success..

                    A 1 Reply Last reply
                    0
                    • R Rajeshwar Code Developer

                      yes i want to change every row of the description...

                      try and try untill reach success..

                      A Offline
                      A Offline
                      Arun Jacob
                      wrote on last edited by
                      #11

                      Rajeshwar Code- Developer wrote:

                      yes i want to change every row of the description...

                      style treeview. :)

                      Arun Jacob http://codepronet.blogspot.com/

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups