Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,386 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,200 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
post 29 Aug, 2008 - 12:40 AM
Post #1


New D.I.C Head

*
Joined: 15 Apr, 2007
Posts: 33


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

Go to the top of the page

andiyuniar
post 2 Sep, 2008 - 08:38 PM
Post #2


New D.I.C Head

*
Joined: 15 Apr, 2007
Posts: 33


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

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 06:47AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month