Common Custom data source
Common_CustomDataSource_VBNet\CustomDataSourceWebApp_VBNet\Default_TileMapData.aspx.vb
' Copyright 2010 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 

Imports Microsoft.VisualBasic
Imports System
Public Partial Class _Default
  Inherits System.Web.UI.Page
  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    ' Text file containing point information, uploaded via a postback
    Dim postedFile As System.Web.HttpPostedFile = FileUpload1.PostedFile

    ' Read text file content
    Dim streamReader As System.IO.StreamReader = New System.IO.StreamReader(postedFile.InputStream, System.Text.Encoding.ASCII)

    ' Retrieve input color and type parameters.  Set using DropDownList web controls, included in the 
    ' postback parameter list. 
    Dim dropDownListColor As String = Request.Params("DropDownListColor")
    Dim dropDownListType As String = Request.Params("DropDownListType")

    ' Get the ADF Graphics map resource item added at design-time
        Dim adfGraphicsFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality = CType(Map1.GetFunctionality("ADF GraphicsLayer"), ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)

    If adfGraphicsFunctionality Is Nothing Then
      Return
    End If

    ' Clear all previous content in the graphics map resource.
    adfGraphicsFunctionality.GraphicsDataSet.Clear()

    ' Create a new feature graphics layer to store input points.
    Dim featureGraphicsLayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer = New ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer()

    ' Read through the input stream, create ADF points, and add to the feature graphics layer.
    Dim inputString As String
    Dim parserChar As Char() = { ","c }
    Do
      inputString = streamReader.ReadLine()
      If Not inputString Is Nothing Then
        Dim pointString As String() = inputString.Split(parserChar)

        Dim x As Double = Double.Parse(pointString(0))
        Dim y As Double = Double.Parse(pointString(1))

        ' Add point to feature graphics layer
        featureGraphicsLayer.Add(New ESRI.ArcGIS.ADF.Web.Geometry.Point(x, y))
      End If
    Loop While Not inputString Is Nothing

    ' If the feature graphics layer contains at least one point, add it to the graphics map resource (via 
    ' the functionality).
        If featureGraphicsLayer.Rows.Count > 0 Then
            Try
                featureGraphicsLayer.TableName = "Uploaded Points"
                adfGraphicsFunctionality.GraphicsDataSet.Tables.Add(featureGraphicsLayer)

            Catch ex As System.Exception
                'If datatable name with Uploaded points exits , remove it and re-add.
                adfGraphicsFunctionality.GraphicsDataSet.Tables.Remove("Uploaded Points")
                featureGraphicsLayer.TableName = "Uploaded Points"
                adfGraphicsFunctionality.GraphicsDataSet.Tables.Add(featureGraphicsLayer)
            End Try
            ' Create a new marker symbol using the input parameters (color and type).
            Dim simpleMarkerSymbol As ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol = New ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol()

            ' Retrieve user defined color from postback parameters and set symbol color.
            simpleMarkerSymbol.Color = System.Drawing.Color.FromName(dropDownListColor)

            ' Retrieve user defined type from postback parameters and set symbol type.
            If dropDownListType = "Circle" Then
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Circle
            ElseIf dropDownListType = "Square" Then
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Square
            Else
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star
            End If

            ' Define marker size and outline color
            simpleMarkerSymbol.Width = 14
            simpleMarkerSymbol.OutlineColor = System.Drawing.Color.Black

            ' Create simple renderer and apply to feature graphics layer.
            Dim simpleRenderer As ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer = New ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer(simpleMarkerSymbol)

            featureGraphicsLayer.Renderer = simpleRenderer
        End If

    ' Refresh the graphics map resource and toc to see updates.  
    Map1.RefreshResource(adfGraphicsFunctionality.Resource.Name)
    Toc1.Refresh()
  End Sub

End Class