Welcome to Dream.In.Code
Become an Expert!

Join 150,064 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,768 people online right now. Registration is fast and FREE... Join Now!




hidden column in gridview (aspnet.vb)

 
Reply to this topicStart new topic

hidden column in gridview (aspnet.vb)

andiyuniar
12 Jun, 2008 - 02:06 AM
Post #1

New D.I.C Head
*

Joined: 15 Apr, 2007
Posts: 35


My Contributions
hi there...

I want to ask about a gridview.

In my program, i create gridview to display xml data.
But not all data show, there is a data in gridview column that i set into not visible.

And than, i want to read the data in hidden column with gridviewrow, but it didn't work.
I cant find cell index....

so is there any way to solve this problem???


User is offlineProfile CardPM
+Quote Post

Jayman
RE: Hidden Column In Gridview (aspnet.vb)
12 Jun, 2008 - 09:57 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Can you post the code that you are using to get the value from the hidden column?
User is offlineProfile CardPM
+Quote Post

andiyuniar
RE: Hidden Column In Gridview (aspnet.vb)
12 Jun, 2008 - 08:07 PM
Post #3

New D.I.C Head
*

Joined: 15 Apr, 2007
Posts: 35


My Contributions
CODE


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Dim myMap As MapInfo.Mapping.Map
Private Function GetMapObject() As MapInfo.Mapping.Map
        Dim peta As MapInfo.Mapping.Map = MapInfo.Engine.Session.Current.MapFactory.Item(MapControl1.MapAlias)
        If (peta Is Nothing) Then
            peta = MapInfo.Engine.Session.Current.MapFactory.Item(0)
        End If
        Return peta
    End Function

    ' Untuk menampilkan layer-2 yang visible di awal ke layer control
    Protected Sub layerControl_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
    Handles gv_lyrControl.RowDataBound

        Dim objCb As System.Web.UI.WebControls.CheckBox = CType(e.Row.Cells(1).FindControl("cbvis"), System.Web.UI.WebControls.CheckBox)

        'untuk cek layer aktif
        For kk As Byte = 0 To myMap.Layers.Count - 1
            If myMap.Layers.Item(kk).Name.Trim.ToLower = e.Row.Cells(0).Text.ToLower Then
                If myMap.Layers.Item(kk).IsVisible Then
                    objCb.Checked = True
                Else
                    objCb.Checked = False
                End If
            End If
        Next

    End Sub

    Protected Sub btapply_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btapply.Click
        Dim peta As MapInfo.Mapping.Map = GetMapObject()
        Dim flyr As MapInfo.Mapping.FeatureLayer


        For i As Byte = 0 To gv_lyrControl.Rows.Count - 1
            Dim rw As GridViewRow = gv_lyrControl.Rows(i)
            Dim cbvisible As CheckBox = CType(rw.Cells(2).FindControl("cbvis"), CheckBox)
            'MsgBox(rw.Cells(1).Text)

            
            flyr = CType(peta.Layers.Item(rw.Cells(1).Text), MapInfo.Mapping.FeatureLayer)
            
            If cbvisible.Checked = True Then
                flyr.Enabled = True
            Else
                flyr.Enabled = False
            End If
        Next

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="gv_lyrControl" runat="server" AutoGenerateColumns="False" DataSourceID="XmlDataSource1">
            <Columns>
                <asp:BoundField DataField="alias" HeaderText="Nama Layer" SortExpression="alias" />
                <asp:BoundField DataField="name" HeaderText="Tab Name" SortExpression="tab" Visible="false" />
                <asp:TemplateField HeaderImageUrl="~/MapXtremeWebResources/Visible.gif">
                    <ItemTemplate>
                        <asp:CheckBox ID="cbvis" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderImageUrl="~/MapXtremeWebResources/lclabelsource.bmp">
                    <ItemTemplate>
                        <asp:CheckBox ID="cblbl" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/layer.xml">
        </asp:XmlDataSource>
    
    </div>
        <br />
        <asp:Button ID="btapply" runat="server" Text="Apply" />
    </form>
</body>
</html>



this is a part of my program.
The bound field 'name' is hidden, and in Sub btapply_Click,
i call this hidden field with 'rw.Cells(1).Text', but it refer to a template field, not a hidden bound field.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:45PM

Be Social

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

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month