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. Replace data in gridview

Replace data in gridview

Scheduled Pinned Locked Moved ASP.NET
databasearchitecturequestion
8 Posts 4 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.
  • M Offline
    M Offline
    Ma tju
    wrote on last edited by
    #1

    Hello I have a field in my database with three options (unknown, yes, no) and the database stores numbers (1,2,3) I want to replace 1,2,3 with the corresponding unknown, yes or no in a bound datagrid. Any hints? Is it possible?

    ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

    G S N 3 Replies Last reply
    0
    • M Ma tju

      Hello I have a field in my database with three options (unknown, yes, no) and the database stores numbers (1,2,3) I want to replace 1,2,3 with the corresponding unknown, yes or no in a bound datagrid. Any hints? Is it possible?

      ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

      G Offline
      G Offline
      govindi unal
      wrote on last edited by
      #2

      hi after binding the datagrid run a for loop to change text of datagrid

      M 1 Reply Last reply
      0
      • G govindi unal

        hi after binding the datagrid run a for loop to change text of datagrid

        M Offline
        M Offline
        Ma tju
        wrote on last edited by
        #3

        Hi, Where should i run the for loop. what should i read and replace. Thanks as an advanced

        ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

        G 1 Reply Last reply
        0
        • M Ma tju

          Hello I have a field in my database with three options (unknown, yes, no) and the database stores numbers (1,2,3) I want to replace 1,2,3 with the corresponding unknown, yes or no in a bound datagrid. Any hints? Is it possible?

          ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

          S Offline
          S Offline
          Sneha Bisht
          wrote on last edited by
          #4

          first bind gridview with this field use loop for(int i=0; i0: i++) { // now find control where u bind this field value ex label l = (Label)(gridview1.rows[i].findControl("control_name")); string val = l.tostring(); if(val=="1") { l.Text=unknown; } else if(val=="2") { l.Text=yes; } else { l.Text=no; } }

          M 1 Reply Last reply
          0
          • M Ma tju

            Hello I have a field in my database with three options (unknown, yes, no) and the database stores numbers (1,2,3) I want to replace 1,2,3 with the corresponding unknown, yes or no in a bound datagrid. Any hints? Is it possible?

            ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Best way is to write in your SQL. Use Case[^] expression.

            Navaneeth How to use google | Ask smart questions

            M 1 Reply Last reply
            0
            • S Sneha Bisht

              first bind gridview with this field use loop for(int i=0; i0: i++) { // now find control where u bind this field value ex label l = (Label)(gridview1.rows[i].findControl("control_name")); string val = l.tostring(); if(val=="1") { l.Text=unknown; } else if(val=="2") { l.Text=yes; } else { l.Text=no; } }

              M Offline
              M Offline
              Ma tju
              wrote on last edited by
              #6

              Thanks sheha. I have already settle my problem. I insert this code in gridview_RowDataBound

              If e.Row.RowType = DataControlRowType.DataRow Or e.Row.RowType = DataControlRowType.Separator Then
              Dim Idstr As String
              Idstr = CType(e.Row.FindControl("lblId"), Label).Text
              If Idstr = 1 Then
              CType(e.Row.FindControl("lblId"), Label).Text = "Yes"
              If Idstr = 2 Then
              CType(e.Row.FindControl("lblId"), Label).Text = "No"
              End If
              End If

              ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

              1 Reply Last reply
              0
              • N N a v a n e e t h

                Best way is to write in your SQL. Use Case[^] expression.

                Navaneeth How to use google | Ask smart questions

                M Offline
                M Offline
                Ma tju
                wrote on last edited by
                #7

                Thanks navaneeth for your suggestion. I already find another way to solve my problem. Actually its hard for me to understand the article from msdn microsoft. :rolleyes:

                ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

                1 Reply Last reply
                0
                • M Ma tju

                  Hi, Where should i run the for loop. what should i read and replace. Thanks as an advanced

                  ma tju Pengaturcara Perisian Subang Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Subang Jaya MOP (Otai)

                  G Offline
                  G Offline
                  govindi unal
                  wrote on last edited by
                  #8

                  after binding the datagrid If DataGrid1.Items.Count > 0 Then For i = 0 To DataGrid1.Items.Count - 1 if UCase(DataGrid1.Items(i).Cells(columnumber).Text) ="1" Then DataGrid1.Items(i).Cells(3).Text="Unknown" elseif UCase(DataGrid1.Items(i).Cells(columnumber).Text) ="2" Then DataGrid1.Items(i).Cells(3).Text="yes" elseif UCase(DataGrid1.Items(i).Cells(columnumber).Text) ="3" Then DataGrid1.Items(i).Cells(3).Text="no" End If Next End If

                  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