gridview

GridView RowDataBound doesn't fire on postback

On an ASP.NET page, I have a GridView populated with the results of a LINQ query. I'm setting the DataSource in code, then calling DataBind on it. In the GridView's RowDataBound event, I'm selectively hiding links in some GridView fields based on the query results. (For instance, I hide the "Show Parent" link of the row in question ha...

ASP.net 2.0 GridView Columns dependant on multiple columns in the bound result set

I'm working with an ASP.net 2.0 GridView control that is bound to the results of a sql query, so it looks something like this: <asp:GridView ID="MySitesGridView" runat="server" AutoGenerateColumns="False" DataSourceID="InventoryDB" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowCommand="GridView1_RowComman...

Quickest way to display results from a table in .NET 2.0/3.5

Hi, I have a database table (sql server 2008) that I want to view data for, what is the quickest way of displaying this data? (if it could have paging that would be perfect). Would it be a gridview or ? query: select * from testData ...

Can You "Assign" the PageCount Property of an ASP.NET GridView?

I have a web application that is using a data store that has it's own built in paging. The PagedResult class tells me the number of total pages. What I would like to do it (after binding my ASP.NET GridView) do this: MyGridView.PageCount = thePageCount; And then have the GridView magically build the pagination links as it normally wou...

Dynamically built SelectCommand for GridView SqlDataSource in asp.net

I'm working with a GridView that uses a SqlDataSource element that looks like this: <asp:SqlDataSource ID="InventoryDB" runat="server" ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>" SelectCommand="SELECT [Server], [Customer] FROM [Website] WHERE [Owner] = 'someOwner'"> </asp:SqlDataSour...

"Invalid postback or callback argument" with Databound controls

I am getting the following error when an event (Add/Edit/Delete) occurs on my databound control. Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callba...

asp.Net GridView bind custom object with nested List

Hi All, I have a List of custom object, which consist of a custom list. class person{ string name; int age; List<friend> allMyFriends; } class friend{ string name; string address; } I'trying to bind a list of these objects to a GridView and the Grid should create for each friend a column and write the name in it. If some p...

ASP.NET - Hierarchical grid view

Any ideas on how I can acheive 'Hierarchical' gridview? Basically I want when the user clicks on the '+', i "expand" and insert new rows without a full page post back. Does this sound like a lot of AJAX stuff? Or should I read on ASP.NET MVC Please point me in right direction ...

How to create two-row Header for ASP.NET GridView

My data is such that I want to display values for the Employee and the Supervisor for a particular record. Instead of describing it, I'll show you a rough example: Employee Supervisor Name    Last Activity    Count    Name    Last Activity    Count    How can I create this for a GridView? I essentially want 2 rows for the headin...

asp.net gridview sort without data rebind

I am trying to make a gridview sortable which uses a stored procedure as a datasource, I would not want it to rerun the query each time to achieve this. How would I get it to work my current code is: protected override void OnPreRender(EventArgs e) { if (!IsPostBack) { SqlCommand cmd2 = new SqlCommand("SR_Student_Course_List...

Using extension methods within inline databinding context

I'm trying to use some extension methods that I use to apply consistent formatting to DateTime and Int32 - which works absolutely fine in code behind, but I'm having issues with databinding. I get: 'System.DateTime' does not contain a definition for 'ToCustomShortDate' for <%# ((ProductionDetails)Container.DataItem).StartDate.ToCust...

How do I force SqlDataSource to use varchar parameters?

I'm using a SqlDataSource to populate my GridView, because the two seem to be so tightly coupled together. Since this grid shows results of a search, I have a dynamic sql string being written in my codebehind that references parameters I pass in, such as below: sdsResults.SelectParameters.Add("CodeID", TypeCode.String, strCodeID) My p...

[ASP.NET] Expandable Rows on a Gridview

Does anyone have any insight on how to have each row in a Gridview expand to show a DIV or PANEL that has a form of elements, i.e. a simple form of textboxes, etc. I don't need a nested Gridview showing results or using DynamicPopulate. I have tried some techniques from a DataGrid Expandable Row, but ran into some problems trying to acc...

good way to query many databases in ASP.NET

What I'm trying to do is run the same SQL select on many Oracle databases (at least a dozen), and display the output in a Gridview. I've hacked together something that works but unfortunately it's very slow. I think its exacerbated by the fact that at least 1 of the dozen databases will invariably be unreachable or otherwise in an erro...

Getting data from a checkbox inside a template column of asp.net gridview

This seems like something simple, but I can't seem to figure it out! I'm trying to get 2-way data-binding to work on an ASP.net page with a check box as one of the columns. How do I get the updated values (from check boxes) back from the gridview ????? Here is my data type: [Serializable] public class UserRequirements { public str...

ASP.net 2.0 Gridview with Expanding Panel Rows -- How to build Panel "on the fly"

I'm currently building a Gridview that has expandable rows. Each row contains a dynamically created Panel of Form elements. Right now, I have a javascript function that expands (or in my case, makes visible) the panel when an Image is clicked on the Gridview row. My question is... is there a more efficient way of doing this. Instead of ...

ASP.NET GridView CSS issue when sorting turned on

I created a GridView in an ASP.NET application and used the Auto Format tool to apply an attractive style. Now I'm moving the style markup to the CSS sheet and I'm having a weird problem where the text in the header row isn't the correct color (it should be white but it shows up a bright blue). This problem only shows up when I turn so...

How do I get Gridview to render THEAD?

How do I get the GridView control to render the <thead> <tbody> tags? I know .UseAccessibleHeaders makes it put <th> instead of <td>, but I cant get the <thead> to appear. ...

Gridview Column Width in ASP.NET 2.0

How do you control the column width in a gridview control in ASP.NET 2.0? ...

How do I break the a BoundField's HeaderText

In HTML in the td of a table you can break text by using between the words. This also works in the HeaderText of a TemplateItem but not the HeaderText of a BoundField. How do I break up the Header text of a BoundField. ...