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. C# Limitation, what the crap? I can't find my dang TableRow!!!

C# Limitation, what the crap? I can't find my dang TableRow!!!

Scheduled Pinned Locked Moved C#
helpcsharpquestionasp-netdesign
6 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.
  • C Offline
    C Offline
    cablesforless
    wrote on last edited by
    #1

    I'm tyring to access a tablerow's text in C# to change it. I know I can do it by simply typing table_row_name.Text; BUT, I have so many different table rows that it would be easyer to use a loop and adentify them with a string rather than directly. HOW CAN I DO THIS? I've tried using ((TableRow).FindControl("FCFC1").Text) = e.Row.Cells[1].Text; as a test.... but I get this error: "CS0118: 'System.Web.UI.WebControls.TableRow' is a 'type' but is used like a 'variable'" HELP ME OUT PLEASE Stuck in a trans from asp to asp.net:wtf:

    C C 2 Replies Last reply
    0
    • C cablesforless

      I'm tyring to access a tablerow's text in C# to change it. I know I can do it by simply typing table_row_name.Text; BUT, I have so many different table rows that it would be easyer to use a loop and adentify them with a string rather than directly. HOW CAN I DO THIS? I've tried using ((TableRow).FindControl("FCFC1").Text) = e.Row.Cells[1].Text; as a test.... but I get this error: "CS0118: 'System.Web.UI.WebControls.TableRow' is a 'type' but is used like a 'variable'" HELP ME OUT PLEASE Stuck in a trans from asp to asp.net:wtf:

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

      cablesforless wrote:

      ((TableRow).FindControl("FCFC1").Text) = e.Row.Cells[1].Text;

      Well, of course. That's what you've said, that TableRow is a variable. You can use foreach to iterate over the rows, and then use code like this, replacing TableRow with the name of the variabgle that hodls the row. Probably e.Row.FindControl("FCFC1").Text = e.Row.Cells[1].Text; Of course, your code would be better if it was not on one line, and it made sure that a control was found.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • C cablesforless

        I'm tyring to access a tablerow's text in C# to change it. I know I can do it by simply typing table_row_name.Text; BUT, I have so many different table rows that it would be easyer to use a loop and adentify them with a string rather than directly. HOW CAN I DO THIS? I've tried using ((TableRow).FindControl("FCFC1").Text) = e.Row.Cells[1].Text; as a test.... but I get this error: "CS0118: 'System.Web.UI.WebControls.TableRow' is a 'type' but is used like a 'variable'" HELP ME OUT PLEASE Stuck in a trans from asp to asp.net:wtf:

        C Offline
        C Offline
        cablesforless
        wrote on last edited by
        #3

        I'm sorry, I just so new to this stuff guys :) be easy on me. I'm accessing it from the OnRowDataBound Event from a Datalist, and throwing the values over to the table. How would I go about usuing your method if I'm already stuck in an event? Very puzzling to me. X|

        C 1 Reply Last reply
        0
        • C cablesforless

          I'm sorry, I just so new to this stuff guys :) be easy on me. I'm accessing it from the OnRowDataBound Event from a Datalist, and throwing the values over to the table. How would I go about usuing your method if I'm already stuck in an event? Very puzzling to me. X|

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

          Sorry, I should have spotted that. The code I gave you: e.Row.FindControl("FCFC1").Text = e.Row.Cells[1].Text; will use the actual row from the event handler, and would not work with foreach. I do worry when people are trying to handle event driven software development and can't decipher a problem like this. Only because it seems people are often jumping in too deep and not fully learning the basics first.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          C 1 Reply Last reply
          0
          • C Christian Graus

            Sorry, I should have spotted that. The code I gave you: e.Row.FindControl("FCFC1").Text = e.Row.Cells[1].Text; will use the actual row from the event handler, and would not work with foreach. I do worry when people are trying to handle event driven software development and can't decipher a problem like this. Only because it seems people are often jumping in too deep and not fully learning the basics first.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            C Offline
            C Offline
            cablesforless
            wrote on last edited by
            #5

            Well, you have to start somewhere... I can only try. Most people learn by example and don't take every Microsoft Class before trying a little but of trial and error. The world is filled with people who try:). Also, I'm fully aware of what your little snippet does. I guess my question is how to use it. The TableRow doesen't have an OnTextChange event. How do I make create that function?

            C 1 Reply Last reply
            0
            • C cablesforless

              Well, you have to start somewhere... I can only try. Most people learn by example and don't take every Microsoft Class before trying a little but of trial and error. The world is filled with people who try:). Also, I'm fully aware of what your little snippet does. I guess my question is how to use it. The TableRow doesen't have an OnTextChange event. How do I make create that function?

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

              cablesforless wrote:

              Also, I'm fully aware of what your little snippet does. I guess my question is how to use it. The TableRow doesen't have an OnTextChange event. How do I make create that function?

              It can only work inside the event you refered to originally, that's the only place that e exists with the property to return the row.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              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