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. General Programming
  3. C#
  4. object typeconversion syntax error

object typeconversion syntax error

Scheduled Pinned Locked Moved C#
designhelpquestion
3 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.
  • M Offline
    M Offline
    myinstincts
    wrote on last edited by
    #1

    Below is the code written in row editing event of data gridview(in assumption that row editing can only be done if some control like textbox is there) (TextBox)(GridView2.Rows[0].Cells [2]) = "a"; But is this syntax of object conversion correct?It is giving error as system cannot convert type string to system.web.ui.webcontrols

    L K 2 Replies Last reply
    0
    • M myinstincts

      Below is the code written in row editing event of data gridview(in assumption that row editing can only be done if some control like textbox is there) (TextBox)(GridView2.Rows[0].Cells [2]) = "a"; But is this syntax of object conversion correct?It is giving error as system cannot convert type string to system.web.ui.webcontrols

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      yes, because "a" is a string, not a textbox.

      1 Reply Last reply
      0
      • M myinstincts

        Below is the code written in row editing event of data gridview(in assumption that row editing can only be done if some control like textbox is there) (TextBox)(GridView2.Rows[0].Cells [2]) = "a"; But is this syntax of object conversion correct?It is giving error as system cannot convert type string to system.web.ui.webcontrols

        K Offline
        K Offline
        Keith Barrow
        wrote on last edited by
        #3

        Try ((TextBox)(GridView2.Rows[0].Cells [2])).Text = "a"; :)

        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