Tuesday, September 07, 2010

ve: gridview listview gridview

Posted by david on 12. February 2009 10:56

Extreme ASP.NET The Only Data-binding Control You'll Ever Need

Mike Ormond's Blog  Some ASP.NET 3.5 ListView Control Examples

Cutting Edge ListView Tips and Tricks

trying to figure how to get a scrollbar on to the listview.  Main answer I gleaned from this; turns out, you place your listview inside of a div, & give the div, itself, the scrollbar – by modifying the overflow property. 

I set overflow: scroll  on the left div.  I could have used overflow: auto instead. How to programmatically select items (rows) of a ListView in C#.NET

this should be possible, but I can’t find much out there. I’m returning to grid view for display of POI …

I picked up the strategy for Selecting on mouseover from another blog, mentioned a couple days ago.  Here are the details:

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
 
    AddRowSelectToGridView(POIGrid);
    base.Render(writer);
 
}
 
 
private void AddRowSelectToGridView(GridView gv)
{
 
    foreach (GridViewRow row in gv.Rows)
    {
 
        row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
 
        row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
 
        row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(gv, "Select$" + row.RowIndex.ToString(), true));
 
    }

The Render event happens when the page is rendered. It calls the AddRowSelectToGridView method, which iterates through all the rows in the grid, applying clientside(?) properties to each row, namely the onmouseover, onmouseout, click events.   I wasn’t seeing a row object in the listview, that’s why I had to back out.  There was, however, an item object that might do the same thing.

The Official Microsoft ASP.NET Site

got selection style working on POIGrid.

I began to ignore my notes while working on this.  I’ll summarize, before starting a new page.

I tried implementing a listview for the list of parks.  I was trying to avoid paging problems.  Once I got it up, I had touble figuring out how to identify the selected record.  Gridview has that built in, listview doesn’t – or at least not that I could understand.

So, went back to gridview for the master list.  It was pretty easy to get it running again because i didn’t fall into all the traps along the way.  Got it down to one column, with the key column hidden. Got it serving as the parameter for detailsview. Got the scroll action working correctly, by nesting it in a div.  & the detailsview is updating correctly.

I have a literal right above the POIgrid … it is updated with address on the SelectedIndexChanged event.  It happens too quick, because it is showing the address of the previously selected item.  I ran into this problem last week, so I’ll have to check notes & figure out wtf.

2009_02_10

Comments

Add comment


 

biuquote
Loading