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.