Asp.Net GridView

Posted by user329419 on Stack Overflow See other posts from Stack Overflow or by user329419
Published on 2010-04-30T18:19:05Z Indexed on 2010/04/30 19:27 UTC
Read the original article Hit count: 316

I need to hide columns in GridView Then access the values of these in the GridViewSelectedIndexChanged using vb.net. When I set DataBound columns is false cant acces the values. Please help.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" BorderStyle="Outset" CellPadding="4" DataSourceID="odsA02_Tracking"
            Font-Size="Small" 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" PageSize="30">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="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="FullName" HeaderText="Client Name" ReadOnly="True" SortExpression="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:BoundField DataField="Instance_ID" HeaderText="Instance_ID" SortExpression="Instance_ID"  Visible=True />

                <asp:TemplateField Visible=False>
                <ItemTemplate>
                <asp:HiddenField ID=hdnSeqID Value='<%#Eval("Seq_ID") %>' runat=server/>                 
                </ItemTemplate>           

                </asp:TemplateField>

                <asp:TemplateField  HeaderText="FormCode" Visible=false>
                <ItemTemplate>
                <asp:HiddenField ID=hdnFormCode Value='<%#Eval("Form_Code") %>' runat=server/>                 
                </ItemTemplate>           

                </asp:TemplateField>
            </Columns>



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

        'fill text box's with values from selected row
        ' store values from selected row        
               Dim seqID As String = CType(GridView1.SelectedRow.FindControl("hdnSeqID"), HiddenField).Value
        Dim formCode As String = CType(GridView1.SelectedRow.FindControl("hdnFormCode"), HiddenField).Value
End Sub

© Stack Overflow or respective owner

Related posts about gridview

Related posts about datadatagridtemplatecolu

  • Asp.Net GridView

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I need to hide columns in GridView Then access the values of these in the GridViewSelectedIndexChanged using vb.net. When I set DataBound columns is false cant acces the values. Please help. <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"… >>> More