Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 244,303 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 781 people online right now. Registration is fast and FREE... Join Now!




Get value from hidden column in gridview

 
Reply to this topicStart new topic

Get value from hidden column in gridview

andiyuniar
29 Aug, 2008 - 12:40 AM
Post #1

New D.I.C Head
*

Joined: 15 Apr, 2007
Posts: 35



Thanked: 1 times
My Contributions
hi there...

I want to ask, how to get a value from hidden column in gridview?

I create a gridview with five column and the 4th and 5th column, i set not visible.

CODE

<asp:GridView ID="gv_sisd" runat="server" BackColor="White" BorderColor="White" BorderWidth="2px" CellPadding="3"
GridLines="None" AutoGenerateColumns="False" Width="360px" BorderStyle="Ridge" CellSpacing="1">
    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
    <SelectedRowStyle BackColor="#9471DE" ForeColor="White" Font-Bold="True" />
    <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
    <HeaderStyle BackColor="#A6A6A6" Font-Bold="True" ForeColor="Black" />
    <Columns>
        <asp:BoundField HeaderText="No." />
        <asp:BoundField HeaderText="Wilayah" DataField="kode_wilayah" >
            <ItemStyle HorizontalAlign="Left" />
        </asp:BoundField>
        <asp:BoundField DataField="nama" HeaderText="Nama" >
            <ItemStyle HorizontalAlign="Left" />
        </asp:BoundField>
        <asp:BoundField DataField="lambang" HeaderText="Lambang" Visible="False" />
        <asp:BoundField DataField="peta" HeaderText="Peta" Visible="False" />
    </Columns>
    <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
    <AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>


and then i create procedure to modifie the value in gv.
In this procedure, i want to get value from 4th column and store in variabel (lambang).
But, it get nothing....

Can you help me tp solve this problem?
thank you...

CODE

Protected Sub gv_sisd_RowDataBound(ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_sisd.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then

            Dim i As Byte = e.Row.Cells(1).Text.Trim.Length()
            Dim IDwil As String = e.Row.Cells(1).Text
            Dim lambang As String = e.Row.Cells(3).Text
            Dim peta As String = e.Row.Cells(4).Text
            Dim isinya As String = ""

            e.Row.Cells(0).Text = e.Row.RowIndex.ToString() + 1

            If i = 2 Then
                isinya = "PROVINSI"
            ElseIf i = 4 Then
                If e.Row.Cells(2).Text.Trim.Substring(0, 4) = "KOTA" Then
                    isinya = "KOTA"
                Else
                    isinya = "KABUPATEN"
                End If
            End If
            e.Row.Cells(1).Text = isinya
            '---------------------------------------
            e.Row.Cells(2).Text = "<a href=""masuk.aspx?dimana=" & isinya & "&IDwil=" & IDwil & "&nama=" & e.Row.Cells(2).Text & "&lambang=" & lambang & """ target=""_self"" style=""text-decoration: none;color:black"">" & e.Row.Cells(2).Text & "</a>"
        End If
    End Sub


User is offlineProfile CardPM
+Quote Post


andiyuniar
RE: Get Value From Hidden Column In Gridview
2 Sep, 2008 - 08:38 PM
Post #2

New D.I.C Head
*

Joined: 15 Apr, 2007
Posts: 35



Thanked: 1 times
My Contributions
Finally, there is someone that can help me to solve this problem.

CODE

Dim lambang as string = DirectCast(DirectCast(DirectCast(DirectCast(e.row, _
System.Web.UI.WebControls.GridViewRow).DataItem, System.Object), _
System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(3)


thanks for Wely.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 06:04PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month