Morning!
After several hours breaking my mind, finally my code works, but i think is
trash-code, can someone tellme how is the correct way to access the value of
my cells within a datagrid?... in some cases i can access the values with
e.Item.Cells[NumCell].Text, but in other cases i have to do weird thinks
like the following:
TextBox pp; //I know...disgusting!!!
pp= (TextBox) e.Item.Cells[0].Controls[0] ;
int id = Convert.ToInt32(pp.Text );
Bussiness biz = new Bussiness();
pp= (TextBox) e.Item.Cells[1].Controls[0]; // de nuevo la misma chanchada...
biz.UpdateUser(id,pp.Text);
BindData();
Please any information who helpme to understand the way asp.net render this
cells will be welcome!
TIA
Ariel Gimenez
Argentina 5 2352
Ariel,
This is one problem that I come across everytime the grid is in edit mode.
Its perfectly normal (at least in my case).
regards,
Marco
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl... Morning! After several hours breaking my mind, finally my code works, but i think
is trash-code, can someone tellme how is the correct way to access the value
of my cells within a datagrid?... in some cases i can access the values with e.Item.Cells[NumCell].Text, but in other cases i have to do weird thinks like the following:
TextBox pp; //I know...disgusting!!! pp= (TextBox) e.Item.Cells[0].Controls[0] ; int id = Convert.ToInt32(pp.Text ); Bussiness biz = new Bussiness(); pp= (TextBox) e.Item.Cells[1].Controls[0]; // de nuevo la misma
chanchada... biz.UpdateUser(id,pp.Text); BindData();
Please any information who helpme to understand the way asp.net render
this cells will be welcome!
TIA Ariel Gimenez Argentina
Hi Ariel,
This is the way to go unfortunally, you could try to simplify a little it
anyway, maybe using a CommandArgument to receive the ID ( the cells[0] ? )
but to get the rest of the values entered by the users in the controls when
editing you will need to cast them back ,
One advice that I would give you is the use of FindControl( "Control
Name" ) instead of referencing the Controls[] by index, this give you
flexibility to add one or more controls inside the same cell.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl... Morning! After several hours breaking my mind, finally my code works, but i think
is trash-code, can someone tellme how is the correct way to access the value
of my cells within a datagrid?... in some cases i can access the values with e.Item.Cells[NumCell].Text, but in other cases i have to do weird thinks like the following:
TextBox pp; //I know...disgusting!!! pp= (TextBox) e.Item.Cells[0].Controls[0] ; int id = Convert.ToInt32(pp.Text ); Bussiness biz = new Bussiness(); pp= (TextBox) e.Item.Cells[1].Controls[0]; // de nuevo la misma
chanchada... biz.UpdateUser(id,pp.Text); BindData();
Please any information who helpme to understand the way asp.net render
this cells will be welcome!
TIA Ariel Gimenez Argentina
Thanks Ignacio Machin!!!
Ill try the findcontrol, i suppose i will need to asign an id to the
controls in the datagrid hum...
I think my english is worst than my code so here is in spanish...
--translation spanish--
Gracias Ignacio Machin!!!
Voy a probar el findcontrol, supongo que para poder utilizarlo debo
asignarle algun id a los controles del datagrid...
Thanks again
Ariel
Argentina
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2***************@tk2msftngp13.phx.gbl... Hi Ariel,
This is the way to go unfortunally, you could try to simplify a little it anyway, maybe using a CommandArgument to receive the ID ( the cells[0] ? ) but to get the rest of the values entered by the users in the controls
when editing you will need to cast them back , One advice that I would give you is the use of FindControl( "Control Name" ) instead of referencing the Controls[] by index, this give you flexibility to add one or more controls inside the same cell.
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in message news:ex**************@TK2MSFTNGP12.phx.gbl... Morning! After several hours breaking my mind, finally my code works, but i think is trash-code, can someone tellme how is the correct way to access the
value of my cells within a datagrid?... in some cases i can access the values
with e.Item.Cells[NumCell].Text, but in other cases i have to do weird thinks like the following:
TextBox pp; //I know...disgusting!!! pp= (TextBox) e.Item.Cells[0].Controls[0] ; int id = Convert.ToInt32(pp.Text ); Bussiness biz = new Bussiness(); pp= (TextBox) e.Item.Cells[1].Controls[0]; // de nuevo la misma chanchada... biz.UpdateUser(id,pp.Text); BindData();
Please any information who helpme to understand the way asp.net render this cells will be welcome!
TIA Ariel Gimenez Argentina
Hi Ariel,
Of course you should, I paste here a piece of one of my grids just to show
you how to do it, also there is a piece of a handler
<asp:templatecolumn ItemStyle-Width="420" >
<itemtemplate>
<asp:Label CssClass="text" Runat="server" Text='<%#
((Action)Container.DataItem).Comments%>' ID="Label8">
</asp:Label>
</itemtemplate>
<EditItemTemplate>
<asp:TextBox ID="CommentTXT" Runat=server TextMode=MultiLine
Text='<%# ((Action)Container.DataItem).Comments%>'>
</asp:TextBox>
</EditItemTemplate>
</asp:templatecolumn>
In the code behind:
protected void ActionUpdateCommand(object sender,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Action action;
Label id =
(System.Web.UI.WebControls.Label)e.Item.FindContro l("ActionID");
if ( id.Text == "-1" )
{
action = new Action( theAccident);
action.DocStorePath = Server.MapPath( DocStorePath );
theAccident.Actions.Add( action);
}
else
action = theAccident.Actions.Find( Convert.ToInt32( id.Text));
TextBox CommentTXT = (TextBox)e.Item.FindControl("CommentTXT");
action.Comments = CommentTXT.Text;
}
Un Saludo
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl... Thanks Ignacio Machin!!! Ill try the findcontrol, i suppose i will need to asign an id to the controls in the datagrid hum... I think my english is worst than my code so here is in spanish...
--translation spanish-- Gracias Ignacio Machin!!! Voy a probar el findcontrol, supongo que para poder utilizarlo debo asignarle algun id a los controles del datagrid...
Thanks again Ariel Argentina
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:%2***************@tk2msftngp13.phx.gbl... Hi Ariel,
This is the way to go unfortunally, you could try to simplify a little
it anyway, maybe using a CommandArgument to receive the ID ( the cells[0]
? ) but to get the rest of the values entered by the users in the controls when editing you will need to cast them back , One advice that I would give you is the use of FindControl( "Control Name" ) instead of referencing the Controls[] by index, this give you flexibility to add one or more controls inside the same cell.
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in message news:ex**************@TK2MSFTNGP12.phx.gbl... Morning! After several hours breaking my mind, finally my code works, but i
think is trash-code, can someone tellme how is the correct way to access the value of my cells within a datagrid?... in some cases i can access the values with e.Item.Cells[NumCell].Text, but in other cases i have to do weird
thinks like the following:
TextBox pp; //I know...disgusting!!! pp= (TextBox) e.Item.Cells[0].Controls[0] ; int id = Convert.ToInt32(pp.Text ); Bussiness biz = new Bussiness(); pp= (TextBox) e.Item.Cells[1].Controls[0]; // de nuevo la misma
chanchada... biz.UpdateUser(id,pp.Text); BindData();
Please any information who helpme to understand the way asp.net render this cells will be welcome!
TIA Ariel Gimenez Argentina
Thanks again!!!
Salu2
Ariel Gimenez
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:Of*************@tk2msftngp13.phx.gbl... Hi Ariel,
Of course you should, I paste here a piece of one of my grids just to show you how to do it, also there is a piece of a handler
<asp:templatecolumn ItemStyle-Width="420" > <itemtemplate> <asp:Label CssClass="text" Runat="server" Text='<%# ((Action)Container.DataItem).Comments%>' ID="Label8"> </asp:Label> </itemtemplate> <EditItemTemplate> <asp:TextBox ID="CommentTXT" Runat=server TextMode=MultiLine Text='<%# ((Action)Container.DataItem).Comments%>'> </asp:TextBox> </EditItemTemplate> </asp:templatecolumn>
In the code behind:
protected void ActionUpdateCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e) { Action action; Label id = (System.Web.UI.WebControls.Label)e.Item.FindContro l("ActionID"); if ( id.Text == "-1" ) { action = new Action( theAccident); action.DocStorePath = Server.MapPath( DocStorePath ); theAccident.Actions.Add( action); } else action = theAccident.Actions.Find( Convert.ToInt32( id.Text));
TextBox CommentTXT = (TextBox)e.Item.FindControl("CommentTXT"); action.Comments = CommentTXT.Text;
}
Un Saludo -- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in message news:O8**************@TK2MSFTNGP11.phx.gbl... Thanks Ignacio Machin!!! Ill try the findcontrol, i suppose i will need to asign an id to the controls in the datagrid hum... I think my english is worst than my code so here is in spanish...
--translation spanish-- Gracias Ignacio Machin!!! Voy a probar el findcontrol, supongo que para poder utilizarlo debo asignarle algun id a los controles del datagrid...
Thanks again Ariel Argentina
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:%2***************@tk2msftngp13.phx.gbl... Hi Ariel,
This is the way to go unfortunally, you could try to simplify a little it anyway, maybe using a CommandArgument to receive the ID ( the cells[0] ? ) but to get the rest of the values entered by the users in the controls when editing you will need to cast them back , One advice that I would give you is the use of FindControl( "Control Name" ) instead of referencing the Controls[] by index, this give you flexibility to add one or more controls inside the same cell.
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Ariel Gimenez" <arielgimenez@--sacar--esto--yahoo.com> wrote in
message news:ex**************@TK2MSFTNGP12.phx.gbl... > Morning! > After several hours breaking my mind, finally my code works, but i think is > trash-code, can someone tellme how is the correct way to access the value of > my cells within a datagrid?... in some cases i can access the values with > e.Item.Cells[NumCell].Text, but in other cases i have to do weird thinks > like the following: > > TextBox pp; //I know...disgusting!!! > pp= (TextBox) e.Item.Cells[0].Controls[0] ; > int id = Convert.ToInt32(pp.Text ); > Bussiness biz = new Bussiness(); > pp= (TextBox) e.Item.Cells[1].Controls[0]; // de nuevo la misma chanchada... > biz.UpdateUser(id,pp.Text); > BindData(); > > Please any information who helpme to understand the way asp.net
render this > cells will be welcome! > > TIA > Ariel Gimenez > Argentina > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: N. Demos |
last post by:
I have a single row table with fixed dimensioned cells nested inside a
fixed dimensioned div, which has overflow: hidden. The div's dimensions
are such that It should only display the first two...
|
by: N. Demos |
last post by:
I have a single row table with fixed dimensioned cells nested inside a
fixed dimensioned div, which has overflow: hidden. The div's dimensions
are such that It should only display the first two...
|
by: EMW |
last post by:
For my ASP.NET program I want to use the datagrid as a sort of planning
tool.
Based on the information in a XML file, a cell of the datagrid must show an
image...
Well, this is what I would...
|
by: tshad |
last post by:
How do I get blank cells to show in my dataGrid?
I am databinding to my datagrid, but any cells that are blank, don't show.
Normally, you would put an   in the cell to make IE display the...
|
by: cwbp17 |
last post by:
I'm having trouble updating individual datagrid cells.
Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and
car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
|
by: ruca |
last post by:
Hi,
Can anyone give me examples of how can I hightlight cells of my datagrid? I
know that I must use ItemBound event and probably JavaScript.
The thing is that I have a anual calendar,...
|
by: Reny J Joseph Thuthikattu |
last post by:
Hi,
I want to do some validation on the Value change of a Datagrid column.Can
any one tell how do i do it?
Regards
Reny
|
by: johnnyG |
last post by:
I've tried this approach but it's not quite what I want:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles...
|
by: Steve Hershoff |
last post by:
Hi everyone,
I've got a strange one here. There are two datagrids on my page, one nested
within the other. I'll refer to them as the topmost and secondary
datagrids.
In the topmost...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |