Bunch's Blog

One day I'll have a catchy subtitle, one day
posts - 87 , comments - 120 , trackbacks - 0

GridView

There are 12 entries for the tag GridView
Finding Buried Controls

This post is pretty specific to an issue I had but still has some ideas that could be applied in other scenarios. The problem I had was updating a few buttons so their Text values could be set in the code behind which had a method...

Posted On Wednesday, March 28, 2012 2:27 PM | Comments (0) |

Finding a GridViews Edit Control
Here is one way to access a control in a GridView right after a user clicks a button to change from view to edit mode. This example shows a TextBox that gets populated with today's date. The GridView is setup like this:<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="TestID" DataSourceID="SqlDataSource1" onrowdatabound="GridView2_R... > <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button ID="btnEdit" runat="server" Text="Edit" ......

Posted On Friday, December 23, 2011 11:40 AM | Comments (0) |

Using Table Valued Parameters

In SQL Server 2008 you can use table valued parameters which can be pretty useful. In the example I use a very simple one to overcome SQL Server’s lack of having a parameter as an array. The example goes through creating the new type, using it in a stored procedure and calling it from an application (VB.Net in this example). You start off with creating the new type. Under Programmability/Types/User-Defined Table Types create a new table. Here I created a table with a single column to hold an int

Posted On Thursday, November 3, 2011 8:05 AM | Comments (2) |

Accessing Controls Within A Gridview
Sometimes you need to access a control within a GridView, but it isn’t quite as straight forward as just using FindControl to grab the control like you can in a FormView. Since the GridView builds multiple rows the key is to specify the row. In this example there is a GridView with a control for a player’s errors. If the errors is greater than 9 the GridView should display the control (lblErrors) in red so it stands out. Here is the GridView: <asp:GridView ID="gvFielding" runat="server" DataSourceID="sqlFielding" ......

Posted On Friday, June 17, 2011 9:44 AM | Comments (0) |

Vertical Scroll Bars For GridView
Here is an old trick to get vertical scroll bars for a GridView. I find this handy when the end users do not want paging but they also do not want to have a page load a GridView that is a mile long either. The code below shows placing your GridView inside a Panel. The Panel is where the scroll bar option is set. I used “Auto” in the example, this way the scroll bar will only appear if the amount of rows in the GridView exceeds the height set. The trick lies in placing both controls inside a single ......

Posted On Monday, February 8, 2010 12:19 PM | Comments (1) |

Updating Parameter Check
Every now and again you may come across an error when trying to update a database from a data driven control (i.e. gridview, formview) that is tied to a SQL or Object data source. The errors usually are along the lines of “Could not find xxx that has parameters” along with a list of those parameters. Or an error that states there are too many parameters being passed. Aside from looking for typos, counting or lining up the parameters I will use one of these techniques to try and narrow down what may ......

Posted On Friday, October 2, 2009 5:47 AM | Comments (0) |

Passing a GridView value to Javascript
This is a similar technique to the one outlined in this post. The idea is simple, you have a data value that you want to pass to a Javascript function through a button click on a GridView row. The example below shows how to pass a variable, in this case OtherID, to a Javascript function that opens a new modal window which holds a different aspx page. function ShowOther(OtherID) { window.showModalDialog('Oth... + OtherID, 'dialogHeight:600px;dialogW... } In the GridView ......

Posted On Monday, June 8, 2009 7:33 AM | Comments (10) |

Loading Data on a Ajax TabPanel Click
Here is one way to have data load only when a TabPanel is clicked. In my example I have an aspx page with a TabContainer, two TabPanels both with their own ObjectDataSources that fill GridViews. The first tab’s ObjectDataSource and GridView will run on the page load and that is fine since it would be the first thing a user sees. The overall idea is to have the ObjectDataSource for the second tab to not run on the page load and then have the GridView on the second tab databind only when the tab is ......

Posted On Friday, May 15, 2009 10:48 AM | Comments (2) |

Calendar Extender Display – Easier Workaround
This post goes along with this previous post on calendar extender display issues. However the formatting fix I used was much less involved than before. Again I had a GridView with some text boxes for dates that I added the CalendarExtender to. And just like before the GridView had some CSS specific to it’s td which involved padding and text alignment. I added all the CalendarExtender styles to my css file and the extender worked fine but did not look quite right. The current date listing was quite ......

Posted On Friday, May 15, 2009 10:27 AM | Comments (2) |

Calendar Extender Display Issues
I was recently working on a GridView and needed to add a calendar for two of the columns while in edit mode. I added the AJAX CalendarExtender and it returned the selected date with no issues. <EditItemTemplate > <asp:TextBox ID="txtDate1" runat="server" Text='<%# BIND("Date1", "{0: MM/dd/yyyy}") %>'></asp:TextBox> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate1" PopupPosition="Right" CssClass="caltheme" > </cc1:CalendarExtender> ......

Posted On Friday, March 6, 2009 3:49 PM | Comments (5) |

NavigateUrl and EVAL
Here is how you can add a database value to the URL of a HyperLink that is in a GridView. In this example the text displayed is the same as the value added to the URL. Also the data is bound through a SqlDataSource and the “ID” value is from the output of the Select statement the SqlDataSource uses. This is a quick way to put the data in the URL without using any code in the code behind. <asp:TemplateField HeaderText="ID" > <ItemTemplate> <asp:HyperLink ID="hlID" runat="server" Text='<%# ......

Posted On Wednesday, July 30, 2008 2:45 PM | Comments (19) |

Using Ajax Tabs
Prior to utilizing Ajax making a page with tabs was a bit of a pain. I would setup a MultiView and add in Views for each tab. Ajax’s Tab Container control is much easier to use. I’ve listed below the order on a sample aspx file that I setup the various Ajax controls to get it all to work. The only real tricks I saw were to add the ScriptManager and the order of the TabContainer/TabPanel/Conte... The ScriptManager and Tab controls went inside the <div> and I made sure that the toolkit ......

Posted On Tuesday, March 25, 2008 9:03 AM | Comments (2) |

Powered by: