BoundField cells not visible during rowcommand ??

  • Thread starter Thread starter jobs
  • Start date Start date
J

jobs

Can somebody tell me why Jobno and Value BoundFields are not available
during the command SaveParm ? i enter text into the box for Value and
hit the Save button, but all I see is the Parmvalue.



Thanks in advance for any help or information!!



<asp:GridView ID="ParmView" runat="server" SkinID="GridView"
AutoGenerateColumns="False"
DataSourceID="ParmDataSource" AllowSorting="True"
AllowPaging="True" Caption="Paramater Values"
CaptionAlign="Left">
<Columns>
<asp:ButtonField ButtonType="Image" ImageUrl="../
App_Themes/WinXP_Silver/Images/edit.gif" CommandName="EditParm" />
<asp:ButtonField ButtonType="Image" ImageUrl="../
App_Themes/WinXP_Silver/Images/save.gif" CommandName="SaveParm" />
<asp:BoundField DataField="Jobno" Visible="false" />
<asp:BoundField DataField="Parmname" ReadOnly="true"
HeaderText="Parameter" />
<asp:BoundField DataField="Value" ControlStyle-
Width="300px" HeaderText="Value" />
</Columns>
<RowStyle Wrap="False" />
</asp:GridView>


... code behind

Protected Sub RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
rungridview.RowCommand, ParmView.RowCommand
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = sender.Rows(index)

If e.CommandName = "SaveParm" Then
Response.Write(row.Cells(0).Text)
Response.Write(row.Cells(1).Text)
Response.Write(row.Cells(2).Text)
Response.Write(row.Cells(3).Text)
Response.Write(row.Cells(4).Text)
'Jobs.SaveParm(CInt(row.Cells(2).Text), row.Cells(3).Text,
row.Cells(4).Text)
'ParmView.Focus()
'response.Write(row.DataItem("Jobno"))
End If

End Sub
 
Howdy,

Because buttonfield is rendered as
System.Web.UI.WebControls.DataControlLinkButton which is added to cell's
control collection, therefore for cells 0 and 1 you should use:
row.Cells(0).Controls(0).Text
row.Cells(1).Controls(0).Text
 
Back
Top