J
jobs
Given the Gridview below:
When I select the button "Rate" and fall into this code. How can I
reference "carriercode" and others . Apparently selecting the button
does not select the row. I've tried find control, and everything
returns that I must reference and instance of the object.
CommandArgument is being sent corrently. If the button where a
ButtunField I apparently I could get the get the index, But I need the
button to be an asp.net button so that I can disable based on a
condition.
Protected Sub PendingGridView_RowCommand(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
PendingGridView.RowCommand
If e.CommandName = "Rate" Then
ProcessId = e.CommandArgument
Response.Write(ProcessId)
'disregard failed attempts below
'CType(PendingGridView.FindControl("CarrierCode"),
Label).Text = ""
'Dim x As String
'x = CType(PendingGridView.Rows(0).Cells(1).Controls(0),
DataKey .tostring()
'Dim selectRow As GridViewRow = PendingGridView.SelectedRow
'Dim xx As String = selectRow.Cells(3).Text
'Response.Write(xx)
=== snip
<asp:GridView ID="PendingGridView" runat="server"
DataSourceID="PendingSqlDataSource"
AutoGenerateColumns="False" DataKeyNames="ProcessId,DayTag"
SkinID="GridView" Width="600px">
<Columns>
<asp:BoundField DataField="ProcessId" visible=false />
<asp:BoundField DataField="DayTag" HeaderText="Day Tag"
ReadOnly="True" SortExpression="DayTag" />
<asp:BoundField DataField="CarrierCode"
HeaderText="Carrier Code" SortExpression="CarrierCode" />
<asp:BoundField DataField="LastAction"
HeaderText="Last Action" SortExpression="LastAction" />
<asp:BoundField DataField="TotalRecords"
HeaderText="Total Records" SortExpression="TotalRecords" />
<asp:TemplateField HeaderText="Rate">
<ItemTemplate>
<asp:Button ID="Rate" Text="Rate"
CommandArgument='<%#Eval("ProcessId") %>' CommandName="Rate"
Enabled='<%# IIF (( (Container.DataItem("ProcessStateId") = 0) or
(Container.DataItem("ProcessStateId") = 2) or
(Container.DataItem("ProcessStateId") = 4) ) ,"TRUE","FALSE") %>'
runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Export">
<ItemTemplate>
<asp:Button ID="Export" Text="Export"
CommandArgument='<%#Eval("ProcessId") %>' CommandName="Export"
Enabled='<%# IIF(Container.DataItem("ProcessStateId") =
3,"TRUE","FALSE") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When I select the button "Rate" and fall into this code. How can I
reference "carriercode" and others . Apparently selecting the button
does not select the row. I've tried find control, and everything
returns that I must reference and instance of the object.
CommandArgument is being sent corrently. If the button where a
ButtunField I apparently I could get the get the index, But I need the
button to be an asp.net button so that I can disable based on a
condition.
Protected Sub PendingGridView_RowCommand(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
PendingGridView.RowCommand
If e.CommandName = "Rate" Then
ProcessId = e.CommandArgument
Response.Write(ProcessId)
'disregard failed attempts below
'CType(PendingGridView.FindControl("CarrierCode"),
Label).Text = ""
'Dim x As String
'x = CType(PendingGridView.Rows(0).Cells(1).Controls(0),
DataKey .tostring()
'Dim selectRow As GridViewRow = PendingGridView.SelectedRow
'Dim xx As String = selectRow.Cells(3).Text
'Response.Write(xx)
=== snip
<asp:GridView ID="PendingGridView" runat="server"
DataSourceID="PendingSqlDataSource"
AutoGenerateColumns="False" DataKeyNames="ProcessId,DayTag"
SkinID="GridView" Width="600px">
<Columns>
<asp:BoundField DataField="ProcessId" visible=false />
<asp:BoundField DataField="DayTag" HeaderText="Day Tag"
ReadOnly="True" SortExpression="DayTag" />
<asp:BoundField DataField="CarrierCode"
HeaderText="Carrier Code" SortExpression="CarrierCode" />
<asp:BoundField DataField="LastAction"
HeaderText="Last Action" SortExpression="LastAction" />
<asp:BoundField DataField="TotalRecords"
HeaderText="Total Records" SortExpression="TotalRecords" />
<asp:TemplateField HeaderText="Rate">
<ItemTemplate>
<asp:Button ID="Rate" Text="Rate"
CommandArgument='<%#Eval("ProcessId") %>' CommandName="Rate"
Enabled='<%# IIF (( (Container.DataItem("ProcessStateId") = 0) or
(Container.DataItem("ProcessStateId") = 2) or
(Container.DataItem("ProcessStateId") = 4) ) ,"TRUE","FALSE") %>'
runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Export">
<ItemTemplate>
<asp:Button ID="Export" Text="Export"
CommandArgument='<%#Eval("ProcessId") %>' CommandName="Export"
Enabled='<%# IIF(Container.DataItem("ProcessStateId") =
3,"TRUE","FALSE") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>