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