Common Custom data source
Common_CustomDataSource_CSharp\CustomDataSourceWebApp_CSharp\Default_TileMapData.aspx.cs
// 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.
// 


public partial class _Default : System.Web.UI.Page 
{   
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        // Text file containing point information, uploaded via a postback
        System.Web.HttpPostedFile postedFile = FileUpload1.PostedFile;
 
        // Read text file content
        System.IO.StreamReader 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. 
        string dropDownListColor = Request.Params["DropDownListColor"];
        string dropDownListType = Request.Params["DropDownListType"];

        // Get the ADF Graphics map resource item added at design-time
        ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality adfGraphicsFunctionality =
            (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)Map1.GetFunctionality("ADF GraphicsLayer");

        if (adfGraphicsFunctionality == null)
            return;

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

        // Create a new feature graphics layer to store input points.
        ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer featureGraphicsLayer =
            new ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer();
        
        // Read through the input stream, create ADF points, and add to the feature graphics layer.
        string inputString;
        char[] parserChar = { ',' };
        do
        {
            inputString = streamReader.ReadLine();
            if (inputString != null)
            {
                string[] pointString = inputString.Split(parserChar);

                double x = double.Parse(pointString[0]);
                double y = double.Parse(pointString[1]);

                // Add point to feature graphics layer
                featureGraphicsLayer.Add(new ESRI.ArcGIS.ADF.Web.Geometry.Point(x, y));
            }
        } while (inputString != null);

        // 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)
        {
            try
            {
                featureGraphicsLayer.TableName = "Uploaded Points";
                adfGraphicsFunctionality.GraphicsDataSet.Tables.Add(featureGraphicsLayer);
            }
            catch (System.Exception ex)
            {
                //If datatable name with Uploaded points exits , remove ie and re-add.
                adfGraphicsFunctionality.GraphicsDataSet.Tables.Remove("Uploaded Points");
                featureGraphicsLayer.TableName = "Uploaded Points";
                adfGraphicsFunctionality.GraphicsDataSet.Tables.Add(featureGraphicsLayer);
            }

            // Create a new marker symbol using the input parameters (color and type).
            ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol 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")
            {
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Circle;
            }
            else if (DropDownListType.SelectedValue == "Square")
            {
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Square;
            }
            else
            {
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
            }

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

            // Create simple renderer and apply to feature graphics layer.
            ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer simpleRenderer =
                new ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer(simpleMarkerSymbol);

            featureGraphicsLayer.Renderer = simpleRenderer;
        }

        // Refresh the graphics map resource and toc to see updates.  
        Map1.RefreshResource(adfGraphicsFunctionality.Resource.Name);
        Toc1.Refresh();        
    }

}