473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Referencing BoundField DataField of a Datagrid when button of same row is selected ???


Given the Gridview below:

When I select the button "Rate" and fall into this code: How can I
reference "carriercode" and other . 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.
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>

Oct 18 '06 #1
0 2231

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Smith | last post by:
When the code below runs, I get the error: "cannot convert from 'System.Web.UI.WebControls.BoundField' to 'System.Web.UI.WebControls.DataGridColumn'" Is adding a BoundField different than adding...
5
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example,...
0
by: ElGordo | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
0
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
3
by: sloan | last post by:
<asp:BoundField DataField="MyDate" DataFormatString="{0:d}" HeaderText="My Date" /> I have a BoundField being populuated with the "MyDate" column. The MyDate is in a strongly typed DataSet. The...
1
by: jobs | last post by:
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...
1
by: jobs | last post by:
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. ...
0
by: sansie | last post by:
Hi, I have a page which is basically a details view(in inset mode) inside a datalist. The problem is I want to set the field "invoiceID" (of the detailsview) to an invoiceID coming through the...
0
by: dayiku | last post by:
I am trying to retrieve values from a boundfield in a detailsview. protected void BtnViewDetails_Click(object sender, EventArgs e) { // get the gridviewrow from the sender so we...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.