Tuesday, September 07, 2010

VE – grid bound to datatable object

Posted by david on 10. December 2008 22:21

DataReader and DataSet

Binding to DataSet, DataTable, and DataView ( instructions from Telerik site for one of their controls … )

aspnetcontrols12

DataTable tableLayers = new DataTable("Layers");
 
protected void Page_Load(object sender, EventArgs e)
{
    intializeDataTable();
    ListBox1.DataSource = tableLayers;
    ListBox1.DataTextField = "layerID";
    ListBox1.DataBind();
    updateTestTable();
}
private void updateTestTable()
{
    tableLayers.Clear();
            //// get the count of the items on the map
    int layercount = ScubaMap.GetShapeLayerCount();
 
    //// iterate through the map layers, adding the layers to datatable
    for (int i = 0; i < layercount; i++)
    {        
        DataRow row = tableLayers.NewRow();
        row["layerID"] = ScubaMap.GetShapeLayerByIndex(i).ID.ToString();
        row["layerDesc"] = ScubaMap.GetShapeLayerByIndex(i).Description.ToString();
        tableLayers.Rows.Add(row);
    }
    ListBox1.DataBind();
}
 
private DataTable intializeDataTable()
{        
    tableLayers.Columns.Add("layerID", typeof(string));
    tableLayers.Columns.Add("layerDesc", typeof(string));
                          
    return tableLayers;
} 

this worked: created a datatable, a simple listbox

Open Source Draggable ASP.NET Controls  Software by Rob

Latest version

code is convoluted …

Comments

Add comment


 

biuquote
Loading