Advertisement
Advertisement
| 02.13.2008 at 05:39AM PST, ID: 23159497 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: |
Here is the grid:
<asp:GridView ID="examplegrid" runat="server" AutoGenerateColumns="false"
Height="550px" Width="100%">
<AlternatingRowStyle BackColor="AliceBlue" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle />
<EditRowStyle BackColor="#999999" />
<Columns>
<asp:BoundField DataField="Trip_Detail_ID" HeaderText="Trip Nr" />
<asp:TemplateField HeaderText="Origin">
<itemtemplate>
<span style="text-transform:capitalize;"><%#DataBinder.Eval(Container.DataItem, "Orig_Cust_Loc_NM") %></span>
</itemtemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Destination">
<itemtemplate>
<span style="text-transform:capitalize;"><%#DataBinder.Eval(Container.DataItem, "Dest_Cust_Loc_NM") %></span>
</itemtemplate>
</asp:TemplateField>
<asp:BoundField DataField="Leg_Type_DS" HeaderText="Leg Type" />
<asp:BoundField DataField="View_DT" HeaderText="View DT" />
<asp:BoundField DataField="Inld_Request_Status_DS" HeaderText="Leg Status" />
<asp:BoundField DataField="Approver_AN" HeaderText="Approver" />
<asp:BoundField DataField="Leg_Start_DT" HeaderText="Leg Start" />
<asp:BoundField DataField="Leg_End_DT" HeaderText="Leg End" />
<asp:TemplateField>
<headertemplate>
Select
</headertemplate>
</asp:TemplateField>
<asp:TemplateField>
<itemtemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</itemtemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hfTripLegId" value="<%#DataBinder.Eval(Container.DataItem,"Trip_Leg_ID")%>" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The last template with the hidden field is not getting rendered to the browser correctly. It is rendered as:
<td>
<asp:HiddenField ID="hfTripLegId" value="14408201" runat="server" />
</td>
Notice it got rendered as an asp:HiddenField instead of an input control with the type of hidden.
In fact, it looks like anything I try to make hidden in this cell is rendered verbatim in the ASPX file instead of rendering the html version of it.
When I use code like this:
foreach (TableRow tr in examplegrid.Rows)
{
// find the checkbox in the row.
chk = (CheckBox)tr.Cells[9].FindControl("chkSelect");
if (chk.Checked == true)
{
// Get the trip_leg_id
HiddenField hid = (HiddenField)tr.Cells[10].FindControl("hfTripLegId");
tripLegId = hid.Value;
// Do Accept.
business.AcceptTrip(tripLegId);
}
}
The checkbox is found in the cells. So I know I'm using the correct syntax. But the hidden field is not. I've even tried "tr.FindControl("hfTripLegId) and it came out null.
|