Posted by david on 23. December 2008 18:51
//------------------------------------------------------------
protected void UpdateLayerList()
{
// get the count of layers on the map
int layerCount = ScubaMap.GetShapeLayerCount();
// check to see if the baselayer has loaded
if (ScubaMap.GetShapeLayerByIndex(0).DataLoaded)
{
// if loaded, change the title to friendly.
ScubaMap.GetShapeLayerByIndex(0).Title = "Base Layer";
}
// iterate through the map layers, adding the layers to layerList
for (int i = 0; i < layerCount; i++)
{
// First, check if the LayerList contains the current layer
// if LayerList does not contain the layer,
if (!LayerList.Contains(ScubaMap.GetShapeLayerByIndex(i)))
{
// Check to see if current layer is loaded; if yes, add to LayerList, if not
// do nothing, we'll get it the next time.
if (ScubaMap.GetShapeLayerByIndex(i).DataLoaded)
{
LayerList.Add(ScubaMap.GetShapeLayerByIndex(i));
}
}
}
// rebind
Grid1.DataBind();
}
Comments: 0
Filed Under:
Tags:
Posted by david on 17. December 2008 18:40
Where I’m At:
- list collection is powering the grid view.
- Still takes a bit for a layer to update, to register … wondering if I can do something to fix that, cache the layers, make them invisible,
I just realized what is happening with the layer loads & why my baselayer title was not sticking: I was naming the title before the layer loading had completed. When i called the ShapeLayer(0).Title = “Base Layer” & then the databind, the layer was seen, but ShapeLayer.DataLoaded was still false. Whatever I wrote to that property was lost when the layer finished loading and the layer(0) defaults set.
So, knowing that there’s probably a smarter way to do this, i got it working like so:
pageload does the initial datasource statement & the first databind. Then it calls on UpdateLayerList. UpdateLayerList will be used by all other events that change the map. UpdateLayerList checks to see if layer(0) has finished loading & if it has, it changes the title - before carrying on building the layerList.
protected void updateLayerList()
{
// clear out the list
LayerList.Clear();
// get the count of layers on the map
int layercount = ScubaMap.GetShapeLayerCount();
// check to see if the baselayer is loaded
if (ScubaMap.GetShapeLayerByIndex(0).DataLoaded)
{
// if so, change the title.
ScubaMap.GetShapeLayerByIndex(0).Title = "Base Layer";
}
// iterate through the map layers, adding the layers to layerList
for (int i = 0; i < layercount; i++)
{
LayerList.Add(ScubaMap.GetShapeLayerByIndex(i));
//if (!LayerList.Contains(ScubaMap.GetShapeLayerByIndex(i)))
}
// rebind
Grid1.DataBind();
}
this is version 2008_12_17
Comments: 25
Filed Under:
Tags:
Posted by david on 17. December 2008 16:38
Moist, Thick PB cookies:
21/2 cups AP flour
1/2 t baking soda
1 t baking powder
1/4 t salt
2 sticks unsalted butter, softened
2 cups lt. br. sugar (I always use dk)
1 cup x-crunchy pb
3 lg. eggs
2 t vanilla
1 cup roasted salted peanuts, ground to resemble bread crumbs
Whisk 1st 4 ingred, and set aside. Beat butter until smooth and creamy, add sugar& beat until light & fluffy. Scrape down bowl. Beat in PB, then eggs one at a time, then vanilla. Genlty stir dry ingred. into PB mixture, add ground peanuts until just mixed in.
Cover dough w/plastic wrap and chill b/w 3hrs-overnight.
Adjust rack to low-center position in oven and preheat to 350. Line cookie sheets w/parchment. Woriking w/ 2T at a time roll into balls and place on cookie sheet, 2 inches apart. Barely press each ball twice w/ back of fork to make gentle criss-cross design.
Bake 12-13min, until puffed an slightly browned at edges. Cool until set and transfer.
There you go, happy baking!!!
( source )
more:
Peanut Butter Cookies Recipe - 101 Cookbooks
Comments: 36
Filed Under:
Tags:
Posted by david on 16. December 2008 23:07
I was googling some map code ( importshapelayer ) a couple days ago & was surprised ( shocked horrified ) to find one of these blog entries as the second or third result. Damn – these are just disorganized notes as I muddle my way through this map stuff. I really need to write more clearly … &, perhaps, turn on comments … maybe someone out there ( if anybody had the patience to plow through this madness ) maybe someone out there would have some answers …
Moving on - - -
these notes concern using a List<ShapeLayer> collection as a datasource for a gridview. Also looking at LiNQ & List collections.
Where I’m at:
I was able to use a datatable object as a datasource for my gridview in the 12/11 version. That strategy has been bugging me, though: it creates a separate set, a duplicate set, a redundant set of data. The datatable is just mirroring what’s on the map.
- page load
- load map
- load datatable ( at first only a row representing the baselayer )
- update gridview with the datatable
- add another layer ( the hurricane, or a kml file )
- reload datatable with new data
- update gridview with the datatable
what’s been buggin me is that the map can/should provide the same info. I am able to get a list of layers and shapes because that’s how I loaded the datatable. Why should I create a separate dataset that only mirrors what I have.
So i went back to collections, the List<T> … which works, but I can’t yet figure out how to use the list as a datasource. It’s probably right under my freakin nose.
I am able to write:
List<ShapeLayer> LayerList = new List<ShapeLayer>();
List<Shape> ShapeList = new List<Shape>();
protected void Page_Load(object sender, EventArgs e)
{
Grid1.DataSource = LayerList;
Grid1.DataBind();
}
Ok, The above is working. I thought it wasn’t for a while, but turns out it was just taking a bit for the update to kick in.
The setup is this:
layerList, a List<ShapeLayer>, is defined ( initialized? set? ) for the page class:
1: public partial class Storage_2008_12_14_2008_12_14 : System.Web.UI.Page
2: {
3: List<ShapeLayer> LayerList = new List<ShapeLayer>();
on PageLoad, Gridview datasource is set to LayerList, & a databind command is called to seal the deal. ( necessary yet? ) then updateLayerList method is called.
updateLayerList – clears the list, iterates through all of the shapelayers on the map, adding each shapelayer to layerList, then another databind is run.
code for pageload & for the updateLayerList method:
1: public partial class Storage_2008_12_14_2008_12_14 : System.Web.UI.Page
2: {
3: List<ShapeLayer> LayerList = new List<ShapeLayer>();
4:
5: protected void Page_Load(object sender, EventArgs e)
6: {
7: // default title of baselayer is empty - correct that here for presentation
8: ScubaMap.GetShapeLayerByIndex(0).Title = "Base Layer";
9: Grid1.DataSource = LayerList;
10: Grid1.DataBind();
11: updateLayerList();
12: }
13: protected void updateLayerList()
14: {
15: LayerList.Clear();
16: //// get the count of layers on the map
17: int layercount = ScubaMap.GetShapeLayerCount();
18: //// iterate through the map layers, adding the layers to layerList
19: for (int i = 0; i < layercount; i++)
20: {
21: LayerList.Add(ScubaMap.GetShapeLayerByIndex(i));
22: //if (!LayerList.Contains(ScubaMap.GetShapeLayerByIndex(i)))
23: }
24: Grid1.DataBind();
25: }
This is functional ( 12/14 ) but I am getting unexpected behavior:
page loads, grid view loads, giving one record … the base layer. I know that the map data is not fully resolved because the list view does not show the layerID until the next refresh … which is every 10 sec or on the next button event. When the refresh occurs, the gridview correctly shows the ID of the baselayer but the title reverts to “unsaved collection.”
the updateLayerList method:
1: clears out the list
2: iterates through the map getting layer info
3: rebinds
the clear is happening at the List, I thought … & a specific layer Title should not be affected by the LayerList.Clear. It is, though.
next time -
“You can just set the DataSource to be a List<MyObject> and DataBind. You
won't get any help with setting up the columns at design time if you do it
that way - you'll have type in all the details. If you want design time
help consider using an ObjectDataSource that points to a method that returns
the list.” (source)
The ASP Column DataList vs. DataGrid in ASP.NET
Sort GridView with custom collection as DataSource - ASP.NET Forums
.NET ASP.NET Use gridview with generic collection
Northwind Meets Virtual Earth - Generate VE Maps with LINQ VB, using LINQ to generate the datasource for the map: “
“The key takeaway here is that in one LINQ statement we queried over multiple data sources, the Northwind Database and the geocoder.us service, to create a single XML document that conformed to the GeoRSS standard and passed that to the Virtual Earth service to generate our map. As you can see, it's pretty easy to create XML, in this case RSS, from multiple sources with LINQ and Visual Basic 9.”
Posted by david on 11. December 2008 20:03
gridview column alignment is set like this:
Grid1.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Center;
( asp.net c# )
but I’m getting an out of range error … think
didn’t resolve it at all … the columns aren’t seen … think it’s because the grid view is programmatically generated .. the columns aren’t there to be set … I first put it in the page load, then tried it in the oft called update … still got the error. backburner.
another issue: grid is not persistent. when I have a couple layers on the map & the grid has updated – when I click on change icon, for example, the grid resets.
also, changing the grid template did diddly …. do I have the style hard coded somewhere?
v. 2008 12 11
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 …
Posted by david on 10. December 2008 12:12
I think I’ve found the answer to my earlier data object questions.
k –
I’ve got a map, which has layers, which has shapes
the map & the layers are, themselves, data containers. If my question is: what shapes are on the map, I can query the Map object, Map.GetShapeLayerCount … iterate through the map, getting the layers, then iterate through the layers, getting the shapes.
It seemed cumbersome to me. Further, what if I want to provide controls that are bound to the set of layers or the set of shapes … Well, would I then be doing the above iteration every time? Then how to move things around?
Now, eventually, the map would be attached to a db .. with the user provided locations … but it would take a lot of users to make for an interesting map .. so I’ll have to be using other data sources …
The map is the presentation data container for an array (npi) of data sources. Further, the user could be adding points to the map, not immediately represented in the data source of the layer their adding to.
When G goes to the bead store, she walks around the bead store with a tray. She picks out beads from the bagillion different containers of beads in the store, then uses that tray of beads for her final work. I’m reaching a little, but the map is the tray. The datasources are the bead bins. If she could materialize new beads out of thin air, the metaphor would be a little more perfect … because the user can add shapes to the map, with relevant data, and upload the newly defined shape to whatever datasource they have permissions to.
If the map topic was Seattle sightseeing spots, one datasource might be a public db, or two … ( merged, say hiking sites & coffee sites ) … plus add in a spot that a friend told ‘em about. Then the work is finished. We can take that new set of points & save it to the user owned datatank.
My earlier problem was figuring out how to bind the controls, for layer selection & shape selection to the map. Plus it needs to be super easy to drop a point, or edit a point.
I could run a temp table in the sites SQL DB, but that would still involve frequent trips back to the server. What I need is an in memory data object.
I reviewed collections earlier … & those worked ok … I need, however, tables. Admittedly. my programming skillz are weak & I can’t see a way to do it using self defined objects.
But, now I do – & the clincher is that I get to use tables, just in memory tables:"
( Source: Esposito, Dino. "Chapter 8 - ADO.NET Data Containers". Programming Microsoft ASP.NET 3.5. Microsoft Press. © 2008. Books24x7. <http://common.books24x7.com/book/id_24532/book.asp> (accessed December 10, 2008) )
“ The System.Data namespace contains several collection-like objects that, combined, provide an in-memory representation of the DBMS relational programming model. The DataSet class looks like a catalog, whereas the DataTable maps to an individual table. The DataRelation class represents a relationship between tables, and the DataView creates a filtered view of a table's data. In addition, the System.Data namespace also supports constraints and a relatively simple model of indexing.
The DataTable object represents one table of in-memory data. Mostly used as a container of data within a DataSet, the DataTable object is also valid as a stand-alone object that contains tabular data. The DataTable and DataSet are the only ADO.NET objects that can be remoted and serialized. Just as with a DataSet, a DataTable can be created programmatically. In this case, you first define its schema and then add new rows. The following code snippet shows how to create a new table within a DataSet:
DataSet ds = new DataSet();DataTable tableEmp = new DataTable("Employees");tableEmp.Columns.Add("ID", typeof(int));tableEmp.Columns.Add("Name", typeof(string));ds.Tables.Add(tableEmp);
The table is named Employees and features two columns—ID and Name. The table is empty because no rows have been added yet. To add rows, you first create a new row object by using the NewRow method:
DataRow row = tableEmp.NewRow();row["ID"] = 1;row["Name"] = "Joe Users";tableEmp.Rows.Add(row);
“
Woot !
Posted by david on 9. December 2008 22:14
trying to add the ajax control toolkit to VS08. Kept erroring:
“there was an error loading types from assembly ajaxcontroltoolkit request for the permission” more or less
This solved it:
The Solution:
Start > Control Panel > Administrative Tools > Microsoft .NET Framework 2.0 Configuration. After it fully loads (sometimes takes a bit), fully expand My Computer in the navigation tree and click Runtime Security Policy. In the right hand pane, choose Adjust Zone Security. Leave the default option (Make changes to this computer) and hit next. Choose Local Intranet and change the trust level to Full Trust. Then choose next and then finish. Restart Visual Studio 2005 and you should be all set. ( source )
Comments: 49
Filed Under:
Tags:
asp.net
Posted by david on 9. December 2008 17:32
Petite Sirloin
roasted brussels sprouts
Sauteed Mushrooms:
2 cups of baby portabella, sliced thick
1/2c red wine
1/2 c beef broth
1c diced onion
butter
Start by browning the steak in a big fry pan.
Removed the steak, Put aside, added tbs or so of butter to pan;
When melted, added onion;
Sauted onion for a couple minutes.
Added mushrooms, wine, & broth
Reduced.
Tasted fine, but was too much liquid.
Poured pan into a mixing bowl, added another tab butter back to the pan. Melted down. Sprinkled a tbs or so of flour. cooked for a while, whisking.
Then added the shrooms back in. Thickened up immediately.
Put the browned steak into a preheated Creuset, poured the shrooms over, filling the pan & covering the steaks. covered with foil. 325 deg oven.
think I left it in the oven too long, steak was a little toooo cooked, but the mushrooms were dandy. G sez more salt, as usual.
original shroom recipe:
1 (10.5 oz) Can Beef Broth
1/2 C. Diced Onions
2 (8 oz Cans or Jars) of Small Whole Mushrooms (Plus Juice of One)
1/3 C. Burgundy Wine
Preparation:
Place the beef broth in a saucepan and simmer the onion for 15 minutes. Add mushrooms
and wine and simmer for another 15 minutes and serve.
Comments: 31
Filed Under:
Tags: