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. Problem with GridView

Problem with GridView

Scheduled Pinned Locked Moved ASP.NET
csharphelpquestionasp-netwpf
7 Posts 3 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
    Purish Dwivedi
    wrote on last edited by
    #1

    I have created my webapp in ASP.NET, C# and MS-Access. in Table I have cell value as, 1 and 0. At the time of binding I want to convert it to On and Off respecively. How can I do it? Please help , as I am new to .NET This is my code. private void Binding() { // create the connection OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/GmoteDeviceControl/App_Data/DeviceCtrl.mdb;User Id=admin;Password=;"); // Open the connection con.Open(); // create the DataSet DataSet ds = new DataSet(); // create the adapter and fill the DataSet OleDbDataAdapter da = new OleDbDataAdapter("Select DEVICE_NAME,CURRENT_STATE from SUBSCRIBER_DEVICES", con); da.Fill(ds); //Binding DataSource with GridView GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); // close the connection con.Close(); } Thank You.

    C N 2 Replies Last reply
    0
    • P Purish Dwivedi

      I have created my webapp in ASP.NET, C# and MS-Access. in Table I have cell value as, 1 and 0. At the time of binding I want to convert it to On and Off respecively. How can I do it? Please help , as I am new to .NET This is my code. private void Binding() { // create the connection OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/GmoteDeviceControl/App_Data/DeviceCtrl.mdb;User Id=admin;Password=;"); // Open the connection con.Open(); // create the DataSet DataSet ds = new DataSet(); // create the adapter and fill the DataSet OleDbDataAdapter da = new OleDbDataAdapter("Select DEVICE_NAME,CURRENT_STATE from SUBSCRIBER_DEVICES", con); da.Fill(ds); //Binding DataSource with GridView GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); // close the connection con.Close(); } Thank You.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Purish Dwivedi wrote:

      Please help , as I am new to .NET

      Then why are you writing data driven ASP.NET code ? That's at least three things you're trying to learn at once. Is it for school, or work ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • P Purish Dwivedi

        I have created my webapp in ASP.NET, C# and MS-Access. in Table I have cell value as, 1 and 0. At the time of binding I want to convert it to On and Off respecively. How can I do it? Please help , as I am new to .NET This is my code. private void Binding() { // create the connection OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:/GmoteDeviceControl/App_Data/DeviceCtrl.mdb;User Id=admin;Password=;"); // Open the connection con.Open(); // create the DataSet DataSet ds = new DataSet(); // create the adapter and fill the DataSet OleDbDataAdapter da = new OleDbDataAdapter("Select DEVICE_NAME,CURRENT_STATE from SUBSCRIBER_DEVICES", con); da.Fill(ds); //Binding DataSource with GridView GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); // close the connection con.Close(); } Thank You.

        N Offline
        N Offline
        Nishant Singh
        wrote on last edited by
        #3

        Try Using RowDataBound event

        P 2 Replies Last reply
        0
        • N Nishant Singh

          Try Using RowDataBound event

          P Offline
          P Offline
          Purish Dwivedi
          wrote on last edited by
          #4

          thanks

          P 1 Reply Last reply
          0
          • N Nishant Singh

            Try Using RowDataBound event

            P Offline
            P Offline
            Purish Dwivedi
            wrote on last edited by
            #5

            Thanks for previous reply. It worked for me. I have ON or OFF values in a GridView cell. Based on this value I want to show a button (opposite Toggle (OFF/On) correspondingly) in another cell. This is my code. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.Cells[2].Text== "0") e.Row.Cells[2].Text = "OFF"; else e.Row.Cells[2].Text = "ON"; } please help. Thanks...

            C 1 Reply Last reply
            0
            • P Purish Dwivedi

              Thanks for previous reply. It worked for me. I have ON or OFF values in a GridView cell. Based on this value I want to show a button (opposite Toggle (OFF/On) correspondingly) in another cell. This is my code. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.Cells[2].Text== "0") e.Row.Cells[2].Text = "OFF"; else e.Row.Cells[2].Text = "ON"; } please help. Thanks...

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              You seem to have some trivial work to do, and not be able to work out how to do any of it. Why is this ? Surely no-one is paying for this code, when you have no clue what you're doing ? Just put a button in a column. The cell itself will tell you if your button has to turn it off, or on.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              1 Reply Last reply
              0
              • P Purish Dwivedi

                thanks

                P Offline
                P Offline
                Purish Dwivedi
                wrote on last edited by
                #7

                thanks for the reply, but a new problem is, that it is changing my column header also. Any help would be appreciated. Thank YOu

                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