我想隱藏GridView中的asp.net中的列,然後使用vb.net訪問GridViewSelectIndexChanged中的值。我在GridView中使用隱藏的字段。當我嘗試訪問使我不要設置在這裏的實例錯誤對象引用的代碼隱藏字段asp.net
<asp:GridView ID="GridView1" runat="server" OnSorting="GridView1_OnSorting" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
BorderStyle="Outset" CellPadding="4" DataSourceID="odsA02_Tracking"
ForeColor="#333333" GridLines="Vertical" Style="border-right: #0000ff thin solid;
table-layout: auto; border-top: #0000ff thin solid; font-size: x-small; border-left: #0000ff thin solid;
border-bottom: #0000ff thin solid; font-family: Arial; border-collapse: separate" Font-Size="Small" PageSize="30">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:boundfield datafield="Since" HeaderText="Submit Date" ReadOnly=true SortExpression="Since" />
<asp:BoundField DataField="Started_By" HeaderText="Submitted By" SortExpression="Started_By" />
<asp:BoundField DataField="Client_FullName" HeaderText="Client Name" ReadOnly="True" SortExpression="Client_FullName" />
<asp:BoundField DataField="Product_Desc" HeaderText="Product" ReadOnly="True" SortExpression="Product_Desc" />
<asp:BoundField DataField="Branch_List" HeaderText="Branch" ReadOnly="True" SortExpression="Branch_List" />
<asp:BoundField DataField="Event_AssignedID" HeaderText="Assigned To" ReadOnly="True"
SortExpression="Event_AssignedID" />
<asp:BoundField DataField="DaysElapsed" HeaderText="Days Open" ReadOnly="True" SortExpression="DaysElapsed" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:TemplateField HeaderText=Instance_ID >
<ItemTemplate>
<asp:HiddenField ID=lblInstanceID Value='<%#Eval("Instance_ID") %>' runat=server>
</asp:HiddenField>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=Seq_ID>
<ItemTemplate>
<asp:HiddenField ID=lblSeqID Value='<%#Eval("Seq_ID") %>' runat=server/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=Form_Code>
<ItemTemplate>
<asp:HiddenField ID=lblFormCode Value='<%#Eval("Form_Code") %>' runat=server/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Dim Instance_ID As String
Dim Seq_ID As String
Dim Form_Code As String
Dim PARMS As String
Dim DestinationURL As String
Dim DestinationParms As String
Dim instanceID As String = CType(GridView1.FindControl("lblInstanceID"), HiddenField).Value
End sub
如何在沒有FindControl的情況下訪問它們 – shoakat 2010-04-30 18:25:59