index | search | no replies | posting guidelines | help login | register
Index » Products » ASP DataGrid
search this forum:
:: Some questions on DataGrid :: (9)Post a New Message | Post a Reply
May 12 2004, 2:55 PM
 Some questions on DataGridPost a Reply
 Yimei

View this author's profile Send this author a private message

from: Myrtle Creek, OR

Some questions on DataGrid
  • when clicking on column label to sort, I got: Incorrect syntax near the keyword 'ORDER'.

  • add .title, but does not display grid title

  • what is the equivalent function to ASPreport's user defined parameter in grid?
    example: The calling report has insert hyperlink to pass parameter named dco.  In the linked page grid.asp, trying to get the dco passed to strParam1 from the linking report.
    'Build an SQL command statement
    strSQL = "SELECT *  FROM Myview  WHERE dco= '"& strParam1 &"' ORDER  BY provname"
Thaks for all your help!




May 12 2004, 2:58 PM
 Re: Some questions on DataGridPost a Reply
 whichman

View this author's profile Send this author a private message Visit author's homepage

from: Laurel, MD

About the DataGrid:
1. when clicking on column label to sort, I got: Incorrect syntax near the keyword 'ORDER'.

This is a know bug and will soon be fixed.
DO NOT add any ORDER BY clauses to your command. This is because it disrupts the Multiple column-wise sorting.

2. add .title, but does not display grid title

The title is not displayed on your HTML page. It is used for the exported data e.g. It will be the name of the Excel worksheet, HTML Print document etc. If you want it displayed let me know

3. what is the equivalent function to ASPreport's user defined parameter in grid?
example: The calling report has insert hyperlink to pass parameter named dco.  In the linked page grid.asp, trying to get the dco passed to strParam1 from the linking report.
'Build an SQL command statement
strSQL = "SELECT *  FROM Myview  WHERE dco= '"& strParam1 &"' ORDER  BY provname"


Report Parameters are properties of the Report Wizard, they are not part of the DataGrid. This was a design requirement because the Wizard generates the SQL statements while the DataGrid accepts an SQL statement. So you can be more flexible with the DataGrid.
In the example you stated above, you can do something like this:

1. Create a view with provname as the default sort order
2. Select from the view where some_field = some_parameter e.g. Session, Request etc.

'declare variables
  Dim objGrid  
  
  
' Create an instance of DataGrid
  Set objGrid = Server.CreateObject("AspWebSolution.DataGrid")  
  
  With objGrid  
    'Set your command statement  
     .Command = GetSQL  
      
    'Create a databse connection  
     .CreateConnection (GetConnectionString)  
      
    'Display the data grid  
     .Display  
  End  With  
  
'distroy objects
  Set objGrid =  Nothing
  
  
  Function GetConnectionString()
     Dim svr, db, usr, pwd
     If Session("Region")= "West" Then
         db= "acme_west"
     Else
         db= "acme"
     End  Select
     Select  Case  
         Case ....
     End  Select
  
     GetConnectionString = "Provider=MSDASQL;Driver={SQL Server};"& _  
       "Server= "&   svr ";Database= "&& db & ";"& _  
       "User ID= "&   usr ";Password= "&& pwd ";"&
  End  Function
  
  Function GetSQL()
     Dim strSQL
     strSQL = "SELECT * FROM Orders"
     If Not  CBool(Session("IsAdmin"))  Then
         strSQL = strSQL & " WHERE EMPID= "&  CInt(Session("EmployeeID"))
     End  If
     GetSQL=strSQL
  End  Function





-------------------------
Master of the Game
May 13 2004, 3:29 PM
 Re: Some questions on DataGridPost a Reply
 Yimei

View this author's profile Send this author a private message

from: Myrtle Creek, OR

2 more questions:
1. After adding "HAVING clause" (HAVING EntityID >= 1) to my sql statement, the 3 filter boxes above the DataGrid disappeared.
2. The export function (above the DataGrid) does not seem to work for me.
Please help. Thanks.

May 14 2004, 6:19 AM
 Re: Some questions on DataGridPost a Reply
 ghost

View this author's profile Send this author a private message Visit author's homepage

from: Washington, DC

I tried the following statement and it works.
SELECT pub_id,  total = SUM(ytd_sales)  FROM titles  GROUP  BY pub_id HAVING SUM(ytd_sales) > 40000

However, I will continue testing. Can you please send me a sample of your SQL Statement so I can test it.

2. About exporting, I forgot to add:
Make sure you create your datagrid object before adding any HTML text as follows:

<%
      
      Dim objGrid
      Set objGrid = Server.CreateObject("AspWebSolution.DataGrid")
      With objGrid
          .Command = "SELECT ProductName, UnitPrice,  UnitsInStock, UnitsOnOrder, Discontinued  from Products"
          '.HeaderStyle= "background-color:teal;"
      End  With  
      
    'create your connection
    objGrid.CreateConnection(strConn)
%>


<html>
  
<head><title>ACME West</title></head>
  
<body>

<%
'put this where you want the grid to appear  
   objGrid.Display
    
'clear objects  
   Set objGrid =  Nothing
%>

  
</body>
</html>



-------------------------
Ghost
May 25 2004, 8:27 AM
 Re: Some questions on DataGridPost a Reply
 Yimei

View this author's profile Send this author a private message

from: Myrtle Creek, OR

1. I use request.querystring("id") to build the sql statement (the where clause) in my DataGrid page.  Works great!  But when I clicked on Sort or used the filter function above the grid, the javascript call disregarded the request.querystring and returned No records.  
2. The export function in grid is not working for me.  I have <html> below objGrid.CreateConnection(strConn). Please help.

May 26 2004, 5:48 AM
 Re: Some questions on DataGridPost a Reply
 ghost

View this author's profile Send this author a private message Visit author's homepage

from: Washington, DC

BugFix - Grid Export Function
The export function for the grid is now working fine as of version 2.1.55
You can download a copy directly from the link below:

http://www.aspwebsolution.com/products/report_wizard/download.htm




-------------------------
Ghost
May 26 2004, 6:12 AM
 Re: Using Request.QueryString and DataGridPost a Reply
 whichman

View this author's profile Send this author a private message Visit author's homepage

from: Laurel, MD

The reason it disregarded your querystring was because it went into a POST method.

We have not implemented support for custom query string values support as of yet but hopefully we should support it by version 2.5. However, The work around is to store your parameter in a session variable for example:



<%
  
'declare variables
  Const SQL = "SELECT * FROM StudentGrades WHERE StudentID= "
  Dim objGrid, strSQL
  
  If Request("id" ) <> "" Then
     Session("StudentID")=Request("id")
      
     'make sure your StudentID is valid even if empty
      If Session("StudentID")= "" Then
          Session("StudentID")=0
      End  If
  End  If
  
strSQL = SQL & Session("id")  
    
' Create an instance of DataGrid
  Set objGrid = Server.CreateObject("AspWebSolution.DataGrid")    
    
  With objGrid    
     'Set your command statement
     .Command = strSQL  
            
     'Create a databse connection
     .CreateConnection (Connection String)    
  End  With    
%>

<html>
     <head>
          <title>QueryString Example</title>
     </head>
     <body>
          <h2>Hello World</h2>

<%
  
'Display the data grid
objGrid.Display  
    
'distroy objects
  Set objGrid =  Nothing  
  
%>
     </body>
</html>


hope this helps



-------------------------
Master of the Game
Jun 16 2004, 4:43 PM
 Re: Some questions on DataGridPost a Reply
 Yimei

View this author's profile Send this author a private message

from: Myrtle Creek, OR

How do I hide a column? (like Hidden Text Format in report wizard).

Jun 17 2004, 5:00 AM
 Re: Some questions on DataGridPost a Reply
 ghost

View this author's profile Send this author a private message Visit author's homepage

from: Washington, DC

You can hide a column using the Hidden property as follows
objGrid.HiddenColumn(Field Name)
A simple implementation might look like the example below

<%
  
objGrid.Command = "SELECT NameField, AddressField, SalaryField FROM Employees"
  
'if some condition,  then hide the employee's salary
  If Not Session("Department")= "ADMIN" Then
     objGrid.HiddenColumn("SalaryField")
  End  If
  
'create your connection
objGrid.CreateConnection(Connection String)
  
'display your reports
objGrid.Display
  
%>



-------------------------
Ghost
Pages: (1)   [1]

search this forum: