.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Can I drive a Grid View from more than one query ?

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net

So Here's what I'm trying to do.

I have a Calendar Control on one page - the user clicks on a date and goes to another page which displays the details from a diary database for the selected date - works fine so far !

Now, whilst on that second page I want to give the User the choice of displaying all diary entries for the month, or for the year. So I could create a further 2 separate pages that display a GridView for a particular Month or a particular Year but that seems a bit of an over kill.

How can I make the Grid View display from different queries or maybe dynamically change the query depending upon whether a Month or Year is selected?

So my start page with the Calendar Control has this code:

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
        If Page.IsPostBack Then
            Response.Redirect("~/diaryPage.aspx?SelectedDate=" & Calendar1.SelectedDate)
        End If
    End Sub

After which the User gets taken to diaryPage.aspx with the Selected Date from the Calendar Control.

I then created a Table Adapter on the diary Page to query the diary Database with the Selected Date and drive the Grid View to display the details for that Selected Date.


View Complete Post

More Related Resource Links

Using J-Query to show the text in the dialog box from the grid view.


I want to use jquery animated dialog widget(http://jqueryui.com/demos/dialog/#animated) to show the cell value of the data grid view. What I want is when the user clicks on the view button(view button field in data grid view), dialog box should appear showing the text of the log field of the particular row. I just cant find a way to integrate the dialog box code with grid view. Any help will be highly appreciated 

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css). jqGridView is not platform-depending plug-in, it can be used with different web -programming platforms like: ASP .NET/ASP, PHP, JAVA, CGI scripts etc. jqGridView has hight bowser compatibility.

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css

ASP.NET Grid View Paging and GridDataRowBound Problem -



I have a problem displaying data in a Grid View control when I set a row to visible = false when a certain condition is true.

For example, if a DataRowData value has a condition set to true (custom in table) I set the visible property to false, so the data row will not be visible at run time.

The problem is that I'm using paging (10 rows per page) and if 8 of those rows fall into the true condition that won't show the row, that grid view page will only show two rows of data in page 1. The worst scenario is that if I go to page 2 of the grid view and all the rows (10) fall into the true condition, that grid view page will not show any data at all.

How can I show 10 rows of data at all times in a gridview? In other words, I would like to just show the visible rows at all times.

Any help will be greatly appreciated.


Change grid view from table to other HTML layout



You'll have to excuse my ignorance, I'm coming at this from a front-end perspective, and don't really know how to deal with data views in ASP.NET.

Basically, I'm trying to change the layout of some repeated data from a straight table, to something more design-heavy.  It's the same data, just re-organised slightly.  The current ASP.NET code looks like this:

                    <asp:GridView ID="GVMoments" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" PageSize="20" RowHeaderColumn="FirstName"
                        SkinID="GroupSkin" DataKeyNames="moment_id" 
                        <PagerSettings Mode="NumericFirstLast" PageButtonCount="20" Position="TopAndBottom" />
                        <RowStyle />
                                <asp:BoundField DataField="moment_id" HeaderText="moment_id" ReadOnly="True" SortExpression="moment_id"
                                    Visible="False" In

Custom Grid View Header - Grid view Row Created event vs Gridview row databound events ?


Hi Gurus ,

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically  behaviour of both the events in !Postback and page.Postback .

Thanks a tonne in Advance and  any inputs will be valued and appreciated .

show data in grid view error Arithmetic operation resulted in an overflow.



i have a table there is 17 columns in 17 column 3 are number and other are varchar . when i try to display all data of that column error occures.

one more intersting think is when i try to display 6 column then grid show there data an no more error occures. 

when i run my project this error occures in grid view

Arithmetic operation resulted in an overflow. 

text box in the footer of the grid view

hi frnds i hv a grid view that has three columns name,age,phone no.grid view is autogenrated column is true.hw can i take three textboxes in the footer row.if i hv a select buttton in the grid view.i want on click of ths btn corrosponding value get bind to corrosponding textbox in footer row.can i do the coding on any one of the txt change event of these three textboxes.pls help  me

grid view image delete problem

i have a grid in which i am showing a record with image, when user delete the record the image also deleted and when it again enter the record it upload the new image but display the deleted image from the cache example: name.jpeg upload, then deleted, a different file with the name.jpeg upload, it showing the deleted one. 

asp:TemplateField Visible upon condition in grid view

Hi, Is there a way to show or hide a Template Field within a gridview upon a condition in C#? Thanks! 

Hide grid view column if empty

 Hello All, I want to hide a grid view column if that column is empty. How do I do this? I dont have much exp. with grids. Please help me. Thanks in advance.

SQL server management studio 2008 freezes when running a query to Grid result

Hello, I've got problems when I run a Query to a grid result using SQL server management studio 2008 under W7 pro. When I execute the query, the first part of the grid returns, but then it freezes. The query should present a double resultset and contains approx 6100 records, devided over 2 grids. Strange enough, the query runs fine when I export to TXT or to a file. It seems though that the problem is building the grid. When it occurs I cannot end the application bij shutting down de SSMS window, but have to kill the Ssms.exe. In task manager I see only 25% CPU usage and approx 20% memory usage. Nothing exiting there I guess. Suggestions anybody? Microsoft SQL Server Management Studio      10.0.2531.0 Microsoft Analysis Services Client Tools      10.0.3798.0 Microsoft Data Access Components (MDAC)      6.1.7600.16385 Microsoft MSXML      3.0 4.0 5.0 6.0 Microsoft Internet Explorer      8.0.7600.16385 Microsoft .NET Framework      2.0.50727.4952 Operating System      6.0.6001 regards, Pim

Grid view update error

Server Error in '/WebSite6' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:1. Add a "Debug=true" directive at the top of the file that generated the error. Example:   <%@ Page Language="C#" Debug="true" %>or:2) Add the following section to the configuration file of your application:<configuration>    <system.web>        <compilation debug="true"/>    </system.web></configuration> Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.Important: Running applicatio

Why do we need Common view fields in content query web part?

I am a bit confused on the purpose of "CommonViewFields" in CQWP. Almost all the write-ups on the web says that if we need a custom column to be available in the web part's XSL, we need to export the webpart file, add the columns to "CommonViewFields", import the web part to the site. However I noticed that, when I create a custom style template in my "ItemStyle.xsl" and simply add a line like <xsl:value-of select="@MyCustomColmn"/>, then "MyCustomColumn" appears automatically under "Fields to display" in the tool pane as a text box prompt, when I edit the web part and select my style template. I can then simply fill-in my column display name under "MyCustomColumn" and the web part works perfectly fine. (There is NO NEED to export the web part, edit the ".webpart" file and add "commonviewfields" etc..etc..etc) If this works, then what is the real need for "commonviewfields" ? Can someone shed light on this? I am totally confused.. (SharePoint 2010)          

Grid view delete problem

i hav a problem with delete in gridview.my backend is oracle 10g.it throws a ORA-01036 exception when i press delete button.here's my link to code. using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.Odbc; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.OracleClient; public partial class Default2 : System.Web.UI.Page { OracleConnection con = new OracleConnection("Data Source=XE;User ID=SYSTEM;Password=****;Unicode=True"); OracleCommand cmd; DataSet ds = new DataSet(); OracleDataAdapter oda; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { getdata(); } } protected void Button1_Click(object sender, EventArgs e) { cmd = new OracleCommand("insert into petitioner values("+ TextBox6.Text +",'"+ TextBox1.Text +"',"+ TextBox2.Text +","+ TextBox3.Text +","+ TextBox4.Text +","+ TextBox5.Text +")", con); cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); getdata();

speed Performane i create a web site but it very slow run i use tree view and grid view

speed Performane i create a web site but it very slow run i use tree view and grid view but i do it run very fast

how to create a Tree View using passing one sql query

(1)  SELECT a.HD, a.HEAD, a.SH, a.SUBHEAD, a.TRK, a.TRACK, a.TGT, a.TARGET, a.PDC, a.DT_RELEASE, a.STATUS, a.CO  FROM V_HIERARCHY1 a(2) and Data isHR    HR    Rec    Records    Leave    Leave Records    HRL.0001    Policy and Process for leave record.    27.06.2010    30.06.2010    WIP    EdlinkHR    HR    Rec    Records    Leave    Leave Records    HRL.0002    Quarterly Review    01.07.2010    04.07.2010    Planned    EdlinkHR    HR    DB    Database    SAL    Salary    DDS.0001    Calculation of Monthly salary    08.08.2010    09.08.2010    WIP    EdlinkHR    HR    Rec    Records    Ind    Induction Records    HRI.0001    Completion of dossiers.    08.07.2010    10.07.2010    WIP    EdlinkHR    HR &
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend