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. binding gridview

binding gridview

Scheduled Pinned Locked Moved ASP.NET
wpfwcfquestion
2 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.
  • P Offline
    P Offline
    ptvce
    wrote on last edited by
    #1

    Hi i bind a gridview and one of the column show the data this form "aaa#;7" i want show just "aaa", how can i remove "#;7" from the end of data in gridview column when it bindings. Thnaks

    A 1 Reply Last reply
    0
    • P ptvce

      Hi i bind a gridview and one of the column show the data this form "aaa#;7" i want show just "aaa", how can i remove "#;7" from the end of data in gridview column when it bindings. Thnaks

      A Offline
      A Offline
      Artefakt94
      wrote on last edited by
      #2

      Hi, You need to add a RowDataBound to your GridView. Then, in the GridView_RowDataBound(object sender, GridViewRowEventArgs e) method, you'll be able to access e which will provide you with access to the individual cells of that row where you can specify a formatter. Example :

      protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
      {
      GridViewRowEventArgs ea = e as GridViewRowEventArgs;
      if (ea.Row.RowType == DataControlRowType.DataRow)
      {
      DataRowView drv = e.Row.DataItem as DataRowView;
      Object ob = drv["Phone"];
      if (!Convert.IsDBNull(ob))
      {
      Int64 iParsedValue = 0;
      if (Int64.TryParse(ob.ToString(), out iParsedValue))
      {
      TableCell cell = ea.Row.Cells[4];
      cell.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture,
      "{0:(###) ###-####}", new object[] { iParsedValue });
      }
      }
      }
      }

      Light or darkness, we must choose ...

      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