How can I get the value of a column in a datagrid?

Hello. I have a datagird with textboxes on a column item template, I also

have 2 other columns that are hidden and I want to retrieve his value. But I
havent found how to do it.
Thanks very much in advance
This is the code that loops through all rows. find the textboxes controls

Private Sub btnguardarplandesarrollo_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnguardarplandesarrollo.Click
Page.Validate()
If Page.IsValid Then
Dim cont As Int32 = 0
Dim di As DataGridItem
For Each di In dgplandesarrollo.Items
Dim responsabilidadjefe As TextBox = New TextBox
responsabilidadjefe = CType(di.FindControl("jefe"), TextBox)
Dim responsabilidaddh As TextBox = New TextBox
responsabilidaddh = CType(di.FindControl("dh"), TextBox)
Dim responsabilidadcolaborador As TextBox = New TextBox
responsabilidadcolaborador = CType(di.FindControl("colaborador"), TextBox)
Dim tempresa As TextBox = New TextBox
tempresa = CType(di.FindControl("tempresa"), TextBox)
Dim tcolaborador As TextBox = New TextBox
tcolaborador = CType(di.FindControl("tcolaborador"), TextBox)
Dim id As Int32 = dgplandesarrollo.DataKeys.Item(cont)
Try
' Here I want to retrieve the values of second and third columns that are
hidden.
panelmensajes.Visible = True
lblmensajes.Text = "Usted ha ingresado correctamente el plan de desarrollo,
presione el boton siguiente para continuar con la retroalimentacion al jefe
inmediato y las competencias pactadas"
Catch ex As Exception
panelmensajes.Visible = True
lblmensajes.Text = ex.Message
End Try
cont += 1
Next
End If
End Sub


This is my HTML datagrid
<asp:DataGrid id=dgplandesarrollo runat="server" Visible="False"
Width="100%" AutoGenerateColumns="False">
<ItemStyle CssClass="itemdg">
</ItemStyle>
<HeaderStyle Font-Size="Small" Font-Bold="True" CssClass="titulodg">
</HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Competencia y Comportamiento">
<ItemTemplate>
<P>
<asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.cadena") %>' Font-Bold="True" Font-Size="Small" ForeColor="Red">
</asp:Label></P>
<TABLE class=letras id=Table3 borderColor=#000000 cellSpacing=0
borderColorDark=#ffffff cellPadding=1 width="100%" border=1>
<TR>
<TD class=titulodg colSpan=2><FONT size=1>PLAN DE DESARROLLO PARA
ESTE COMPORTAMIENTO</FONT>
</TD></TR>
<TR>
<TD class=letras>Responsabilidad Jefe Inmediato
<asp:RequiredFieldValidator id=RequiredFieldValidator1 runat="server"
ErrorMessage="*" ControlToValidate="jefe"></asp:RequiredFieldValidator></TD>
<TD>
<asp:TextBox id=jefe runat="server" Width="200px" CssClass="textboxes"
Height="38px" TextMode="MultiLine"></asp:TextBox></TD></TR>
<TR>
<TD>Responsabilidad Desarrollo Humano
<asp:RequiredFieldValidator id=RequiredFieldValidator2 runat="server"
ErrorMessage="*" ControlToValidate="dh"></asp:RequiredFieldValidator></TD>
<TD>
<asp:TextBox id=dh runat="server" Width="200px" CssClass="textboxes"
Height="30px" TextMode="MultiLine"></asp:TextBox></TD></TR>
<TR>
<TD>Responsabilidad Colaborador
<asp:RequiredFieldValidator id=RequiredFieldValidator3 runat="server"
ErrorMessage="*"
ControlToValidate="colaborador"></asp:RequiredFieldValidator></TD>
<TD>
<asp:TextBox id=colaborador runat="server" Width="200px"
CssClass="textboxes" Height="38px"
TextMode="MultiLine"></asp:TextBox></TD></TR>
<TR>
<TD>Tiempo Empresa
<asp:RequiredFieldValidator id=RequiredFieldValidator4 runat="server"
ErrorMessage="*"
ControlToValidate="tempresa"></asp:RequiredFieldValidator></TD>
<TD>
<asp:TextBox id=tempresa runat="server" Width="78px"
CssClass="textboxes"></asp:TextBox></TD></TR>
<TR>
<TD>Tiempo Colaborador
<asp:RequiredFieldValidator id=RequiredFieldValidator5 runat="server"
ErrorMessage="*"
ControlToValidate="tcolaborador"></asp:RequiredFieldValidator></TD>
<TD>
<asp:TextBox id=tcolaborador runat="server" Width="78px"
CssClass="textboxes"></asp:TextBox></TD></TR></TABLE>
<HR width="100%" color=red noShade SIZE=3>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="idCompetencia"
HeaderText="idCompetencia"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="idcomportamiento"
HeaderText="idcomportamiento"></asp:BoundColumn>
</Columns>
</asp:DataGrid
0
luisvalencia
1/29/2005 5:20:35 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
524 Views

Similar Articles

[PageSpeed] 24

Since you are using bound columns you can use Text property of individual cell to reach the text to be shown in a cell

di.Cells(1).Text and di.Cells(2).Text inside your loop
Bug [MCSD]
0
bug_bugger
1/31/2005 9:22:30 AM
Reply: