Showing posts with label following. Show all posts
Showing posts with label following. Show all posts

Monday, March 26, 2012

Pass the Items on a post...??

Hi I have to pass the items on a Post to another page using vb.net....I know the following solutions are available for that...

(1) Use an HTML instead of a web form.

(2) Create a simple javascript function to alter the page behavior on the client...But there is a third method which is easy and good that is

(3) Pass the items on a post. Create a custion function to read the current items and send them via an HTTP post...

I neved attempted this and I donno how to do this...Can ne1 help me out how to do this...Ur help will be appreciatedAnd also I do not want to use Query Strings...I know we can redirect that using query strings...But is there any other way like the 3rd one without using query strings...
Here's a code sample that shows how to do what you want:

http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/intro/intro6.src
HI darellnorton,

Thanks for ur reply...But itz posting back to the same form which is not what I want...
One of the biggest differences between ASP and ASP.NET is that in ASP.NET, a Web Form must post back to itself rather than post to a different page.

Historically, developers posted to a different page by setting the form's action attribute. Posting to a separate page used to be a good idea because it made for a cleaner separation of code from HTML. Now, because ASP.NET handles events in the same Web Form in which they're raised, the form must post back to the same page. Even if you set the action attribute of the form to a different page, the Web server finds the runat="server" attribute setting and overrides your action value.
What you want is coming with ASP.NET v2.0, which will be available some time in 2005.
Hi DarrellNorton,

Thanks for ur reply..Yeah I have checked that it is gonna be released in aspv2.0...But how to do that if at all I want to implement it...Is there any way using the javascript to do that...Ur help will be appreciated
What you can do is use Server.Transfer(newPage.aspx), which will transfer control to the new page specified as well as the request object, so data in the request object will be available on the new page.

Try that and let me know how it works.

Pass values

I have the following Stored procedure. There is column named
"tcktreceived" in my database and I want to pass all the rows one by
one to the parameter @dotnet.itags.org.starttime. I don't know how to do it.

CREATE PROCEDURE [twcsan].[usp_DateDiff]
-- Add the parameters for the stored procedure here
@dotnet.itags.org.starttime DateTime

AS
BEGIN
DECLARE @dotnet.itags.org.Diff Varchar(15)
DECLARE @dotnet.itags.org.Day INT
DECLARE @dotnet.itags.org.Hour INT
DECLARE @dotnet.itags.org.Minute INT
DECLARE @dotnet.itags.org.Start_Date DateTime
DECLARE @dotnet.itags.org.End_Date DateTime
DECLARE @dotnet.itags.org.itemReceived DateTime
DECLARE @dotnet.itags.org.ID INT
DECLARE @dotnet.itags.org.message VARCHAR(50)

DECLARE @dotnet.itags.org.table TABLE
(
ItemReceived DateTime,
ID INT,
message text,
Differnce VARCHAR(20)

)
SET NOCOUNT ON;
SET @dotnet.itags.org.Start_Date = @dotnet.itags.org.starttime

SET @dotnet.itags.org.End_Date = GETDATE()
SET @dotnet.itags.org.Day = DATEDIFF( day, @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Hour = DATEDIFF(hour , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = DATEDIFF(minute , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = @dotnet.itags.org.Minute-(@dotnet.itags.org.HOUR* 60)
SET @dotnet.itags.org.Hour = @dotnet.itags.org.Hour-(24* @dotnet.itags.org.Day)
SET @dotnet.itags.org.Diff = CONVERT(Varchar, @dotnet.itags.org.Day) +'d ' + CONVERT(Varchar , @dotnet.itags.org.Hour) +
'h ' + CONVERT(Varchar , @dotnet.itags.org.Minute) +'m'

INSERT INTO @dotnet.itags.org.table(ItemReceived, ID, message, Differnce)
select tck.tcktreceived, tck.ticketid,tckmsg.tcktmessage,@dotnet.itags.org.Diff
from tbtickets tck inner join tbticketsmessages tckmsg
on tck.ticketid = tckmsg.ticketid

select * from @dotnet.itags.org.table

ENDI'm not sure what your after, but try looking at using "Cursor" that might
give you what you need.

Pass values

I have the following Stored procedure. There is column named
"tcktreceived" in my database and I want to pass all the rows one by
one to the parameter @dotnet.itags.org.starttime. I don't know how to do it.
CREATE PROCEDURE [twcsan].[usp_DateDiff]
-- Add the parameters for the stored procedure here
@dotnet.itags.org.starttime DateTime
AS
BEGIN
DECLARE @dotnet.itags.org.Diff Varchar(15)
DECLARE @dotnet.itags.org.Day INT
DECLARE @dotnet.itags.org.Hour INT
DECLARE @dotnet.itags.org.Minute INT
DECLARE @dotnet.itags.org.Start_Date DateTime
DECLARE @dotnet.itags.org.End_Date DateTime
DECLARE @dotnet.itags.org.itemReceived DateTime
DECLARE @dotnet.itags.org.ID INT
DECLARE @dotnet.itags.org.message VARCHAR(50)
DECLARE @dotnet.itags.org.table TABLE
(
ItemReceived DateTime,
ID INT,
message text,
Differnce VARCHAR(20)
)
SET NOCOUNT ON;
SET @dotnet.itags.org.Start_Date = @dotnet.itags.org.starttime
SET @dotnet.itags.org.End_Date = GETDATE()
SET @dotnet.itags.org.Day = DATEDIFF( day, @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Hour = DATEDIFF(hour , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = DATEDIFF(minute , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = @dotnet.itags.org.Minute-(@dotnet.itags.org.HOUR* 60)
SET @dotnet.itags.org.Hour = @dotnet.itags.org.Hour-(24* @dotnet.itags.org.Day)
SET @dotnet.itags.org.Diff = CONVERT(Varchar, @dotnet.itags.org.Day) +'d ' + CONVERT(Varchar , @dotnet.itags.org.Hour) +
'h ' + CONVERT(Varchar , @dotnet.itags.org.Minute) +'m'
INSERT INTO @dotnet.itags.org.table(ItemReceived, ID, message, Differnce)
select tck.tcktreceived, tck.ticketid,tckmsg.tcktmessage,@dotnet.itags.org.Diff
from tbtickets tck inner join tbticketsmessages tckmsg
on tck.ticketid = tckmsg.ticketid
select * from @dotnet.itags.org.table
ENDI'm not sure what your after, but try looking at using "Cursor" that might
give you what you need.

Saturday, March 24, 2012

Pass variable between sub routines

For example, I have the following code:

<%@dotnet.itags.org. Page Language="VB" Debug="True" %>
<script language="vb" runat="server">
Dim var As String

Sub button1_click(sender As object, e As EventArgs)
var = "one"
Response.Write(var)
End Sub

Sub button2_click(sender As object, e As EventArgs)
Response.Write(var)
End Sub
</script>
<html>
<head>
<title>Untitled Document</title>
</head
<body>
<form runat="server">
<asp:Button ID="button1" OnClick="button1_click" Text="one" runat="server"></asp:Button>
<asp:Button ID="button2" OnClick="button2_click" Text="two" runat="server"></asp:Button>
</form>
</body>
</html
The problem is when I click button 2 it response.writes nothing. It should spit out "one". Is there anyway I can share variables between multiple subs?When you click button2, the page is reloaded and "var" is redecleared and the button1 value is gone. You may need use ViewState or Session State to keep the value when page reload or redirect to other page.

Pass variable to URL string

In ASP.NET, the HTML code, I have the following lines to pass variable MyType to the URL parameter:
<P><a id="aHome" runat="Server" class="nav"href="Main.aspx?HeaderType=<%= headertype%>">Home</a></P>
In my Main.aspx page, when I query the string as:Request.QueryString("HeaderType"), it always return me "<%=headertype %>", but not the value of variable: headertype.
How can I pass a variable value to URL string parameter.
Thanks.

You can use :

Response.Redirect("newPage.aspx?value="+TextBox1.Text);

Let me know if you need this to work when the hyperlink is clicked.

Hope this helps !


Thanksfor your answer, it works,
If you can tell me how to pass it to URL string, it will be very helpfull. Hyperlilnk does not have click event.

Wednesday, March 21, 2012

Passing a DataReader between methods and getting RETURN_VALUE

Hi all,

I have the following problem:

I have a private method that returns a SqlDataReader. For this to work I
have not to close the DB connection in the above method. I do this only to
have the possibility to iterate through the entire rows set in a while loop,
located in the calling method.

I have included a few lines of code to get the number of rows fetched from
the DB. I do this with SqlParameter("RETURN_VALUE", SqlDbType.Int) [ I am
using a stored procedure that return @dotnet.itags.org.@dotnet.itags.org.rowcount].

I have found out that I am getting the appropriate value for the stored
procedure parameter ("RETURN_VALUE") ONLY when I have explicitly close the
DB connection. Unfortunately when the control is returned to the calling
method the usual error message

Invalid attempt to Read when reader is closed

is being received as the connection is closed and there's no such DataReader
already.

Does anyone know a workaround for this?

Thanks,

Martin

--------

private SqlDataReader GetReader(string parameter, string date)

{

DateTime MyDateTime;

....//. date parsing

SqlConnection myConn = new SqlConnection(ConnectionString());
SqlCommand myCmd = new SqlCommand();

SqlDataReader myReader=null;

myCmd.CommandType = CommandType.StoredProcedure;
myCmd.Connection = myConn;
myCmd.CommandText = "GetData";
myCmd.CommandTimeout = 250;

SqlParameter Param1 = new SqlParameter();
Param1 = myCmd.Parameters.Add("@dotnet.itags.org.parameter", SqlDbType.VarChar, 12);
Param1.Direction = ParameterDirection.Input;
Param1.Value = parameter;

SqlParameter Param2 = new SqlParameter();
Param2 = myCmd.Parameters.Add("@dotnet.itags.org.date", SqlDbType.VarChar, 20);
Param2.Direction = ParameterDirection.Input;
Param2.Value = MyDateTime.Date.ToShortDateString();

SqlParameter outValue = new SqlParameter();
outValue = myCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
outValue.Direction = ParameterDirection.ReturnValue;

myConn.Open();
myReader = myCmd.ExecuteReader();

// this works only is myConn.Close() is executed but then

// we cannot return a READER to the calling method?

intRowsReturned =
Convert.ToInt32(myCmd.Parameters["RETURN_VALUE"].Value);
return myReader;
}

// the calling method

private void btnSQLGet_Click(object sender, System.EventArgs e)

{

/// ... .

// get the data in a reader

SqlDataReader myReader = GetReader(cboParameter.Text, txtDate.Text);
if (myReader==null)
return;
///....

}You can't read output parameters in a DataReader until the DataReader is
closed. Close the DataReader, and leave the Connection opened to read the
value.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Martin Raychev" <marty_gov@.hotmail.com> wrote in message
news:#RLAe#IKEHA.1892@.TK2MSFTNGP09.phx.gbl...
> Hi all,
>
> I have the following problem:
>
> I have a private method that returns a SqlDataReader. For this to work I
> have not to close the DB connection in the above method. I do this only to
> have the possibility to iterate through the entire rows set in a while
loop,
> located in the calling method.
>
> I have included a few lines of code to get the number of rows fetched from
> the DB. I do this with SqlParameter("RETURN_VALUE", SqlDbType.Int) [ I am
> using a stored procedure that return @.@.rowcount].
>
> I have found out that I am getting the appropriate value for the stored
> procedure parameter ("RETURN_VALUE") ONLY when I have explicitly close the
> DB connection. Unfortunately when the control is returned to the calling
> method the usual error message
>
> Invalid attempt to Read when reader is closed
>
> is being received as the connection is closed and there's no such
DataReader
> already.
>
> Does anyone know a workaround for this?
>
> Thanks,
> Martin
>
> --------
> private SqlDataReader GetReader(string parameter, string date)
> {
> DateTime MyDateTime;
> ....//. date parsing
>
> SqlConnection myConn = new SqlConnection(ConnectionString());
> SqlCommand myCmd = new SqlCommand();
> SqlDataReader myReader=null;
>
> myCmd.CommandType = CommandType.StoredProcedure;
> myCmd.Connection = myConn;
> myCmd.CommandText = "GetData";
> myCmd.CommandTimeout = 250;
> SqlParameter Param1 = new SqlParameter();
> Param1 = myCmd.Parameters.Add("@.parameter", SqlDbType.VarChar, 12);
> Param1.Direction = ParameterDirection.Input;
> Param1.Value = parameter;
>
> SqlParameter Param2 = new SqlParameter();
> Param2 = myCmd.Parameters.Add("@.date", SqlDbType.VarChar, 20);
> Param2.Direction = ParameterDirection.Input;
> Param2.Value = MyDateTime.Date.ToShortDateString();
>
> SqlParameter outValue = new SqlParameter();
> outValue = myCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
> outValue.Direction = ParameterDirection.ReturnValue;
> myConn.Open();
> myReader = myCmd.ExecuteReader();
>
> // this works only is myConn.Close() is executed but then
> // we cannot return a READER to the calling method?
> intRowsReturned =
> Convert.ToInt32(myCmd.Parameters["RETURN_VALUE"].Value);
> return myReader;
> }
>
> // the calling method
> private void btnSQLGet_Click(object sender, System.EventArgs e)
> {
> /// ... .
> // get the data in a reader
> SqlDataReader myReader = GetReader(cboParameter.Text, txtDate.Text);
> if (myReader==null)
> return;
> ///....
> }
1) the return value and parameters values of a stored proc are returned
after all result sets in the proc are returned.
2) a datareader is a forward only cursor, so to get to the return value, you
need to read thru all rows, and result sets
3) a close will read thru all rows and result sets for you, but is not
necessary, the following code will also work:

// process all result sets to get to parameters and reutn value

do
{
while (dr.Read())
;
} while (dr.NextResult())

// now you can access output parameters and the return value

returning a row count makes little sesnse, as you could add up the row
count yourself, as you have to read them all to get to the count return
value.

-- bruce (sqlwork.com)

"Martin Raychev" <marty_gov@.hotmail.com> wrote in message
news:#RLAe#IKEHA.1892@.TK2MSFTNGP09.phx.gbl...
> Hi all,
>
> I have the following problem:
>
> I have a private method that returns a SqlDataReader. For this to work I
> have not to close the DB connection in the above method. I do this only to
> have the possibility to iterate through the entire rows set in a while
loop,
> located in the calling method.
>
> I have included a few lines of code to get the number of rows fetched from
> the DB. I do this with SqlParameter("RETURN_VALUE", SqlDbType.Int) [ I am
> using a stored procedure that return @.@.rowcount].
>
> I have found out that I am getting the appropriate value for the stored
> procedure parameter ("RETURN_VALUE") ONLY when I have explicitly close the
> DB connection. Unfortunately when the control is returned to the calling
> method the usual error message
>
> Invalid attempt to Read when reader is closed
>
> is being received as the connection is closed and there's no such
DataReader
> already.
>
> Does anyone know a workaround for this?
>
> Thanks,
> Martin
>
> --------
> private SqlDataReader GetReader(string parameter, string date)
> {
> DateTime MyDateTime;
> ....//. date parsing
>
> SqlConnection myConn = new SqlConnection(ConnectionString());
> SqlCommand myCmd = new SqlCommand();
> SqlDataReader myReader=null;
>
> myCmd.CommandType = CommandType.StoredProcedure;
> myCmd.Connection = myConn;
> myCmd.CommandText = "GetData";
> myCmd.CommandTimeout = 250;
> SqlParameter Param1 = new SqlParameter();
> Param1 = myCmd.Parameters.Add("@.parameter", SqlDbType.VarChar, 12);
> Param1.Direction = ParameterDirection.Input;
> Param1.Value = parameter;
>
> SqlParameter Param2 = new SqlParameter();
> Param2 = myCmd.Parameters.Add("@.date", SqlDbType.VarChar, 20);
> Param2.Direction = ParameterDirection.Input;
> Param2.Value = MyDateTime.Date.ToShortDateString();
>
> SqlParameter outValue = new SqlParameter();
> outValue = myCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
> outValue.Direction = ParameterDirection.ReturnValue;
> myConn.Open();
> myReader = myCmd.ExecuteReader();
>
> // this works only is myConn.Close() is executed but then
> // we cannot return a READER to the calling method?
> intRowsReturned =
> Convert.ToInt32(myCmd.Parameters["RETURN_VALUE"].Value);
> return myReader;
> }
>
> // the calling method
> private void btnSQLGet_Click(object sender, System.EventArgs e)
> {
> /// ... .
> // get the data in a reader
> SqlDataReader myReader = GetReader(cboParameter.Text, txtDate.Text);
> if (myReader==null)
> return;
> ///....
> }

Passing a DataReader between methods and getting RETURN_VALUE

Hi all,
I have the following problem:
I have a private method that returns a SqlDataReader. For this to work I
have not to close the DB connection in the above method. I do this only to
have the possibility to iterate through the entire rows set in a while loop,
located in the calling method.
I have included a few lines of code to get the number of rows fetched from
the DB. I do this with SqlParameter("RETURN_VALUE", SqlDbType.Int) [ I a
m
using a stored procedure that return @dotnet.itags.org.@dotnet.itags.org.rowcount].
I have found out that I am getting the appropriate value for the stored
procedure parameter ("RETURN_VALUE") ONLY when I have explicitly close the
DB connection. Unfortunately when the control is returned to the calling
method the usual error message
Invalid attempt to Read when reader is closed
is being received as the connection is closed and there's no such DataReader
already.
Does anyone know a workaround for this?
Thanks,
Martin
private SqlDataReader GetReader(string parameter, string date)
{
DateTime MyDateTime;
...//. date parsing
SqlConnection myConn = new SqlConnection(ConnectionString());
SqlCommand myCmd = new SqlCommand();
SqlDataReader myReader=null;
myCmd.CommandType = CommandType.StoredProcedure;
myCmd.Connection = myConn;
myCmd.CommandText = "GetData";
myCmd.CommandTimeout = 250;
SqlParameter Param1 = new SqlParameter();
Param1 = myCmd.Parameters.Add("@dotnet.itags.org.parameter", SqlDbType.VarChar, 12);
Param1.Direction = ParameterDirection.Input;
Param1.Value = parameter;
SqlParameter Param2 = new SqlParameter();
Param2 = myCmd.Parameters.Add("@dotnet.itags.org.date", SqlDbType.VarChar, 20);
Param2.Direction = ParameterDirection.Input;
Param2.Value = MyDateTime.Date.ToShortDateString();
SqlParameter outValue = new SqlParameter();
outValue = myCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
outValue.Direction = ParameterDirection.ReturnValue;
myConn.Open();
myReader = myCmd.ExecuteReader();
// this works only is myConn.Close() is executed but then
// we cannot return a READER to the calling method?
intRowsReturned =
Convert.ToInt32(myCmd.Parameters["RETURN_VALUE"].Value);
return myReader;
}
// the calling method
private void btnSQLGet_Click(object sender, System.EventArgs e)
{
/// ... .
// get the data in a reader
SqlDataReader myReader = GetReader(cboParameter.Text, txtDate.Text);
if (myReader==null)
return;
///....
}You can't read output parameters in a DataReader until the DataReader is
closed. Close the DataReader, and leave the Connection opened to read the
value.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Martin Raychev" <marty_gov@.hotmail.com> wrote in message
news:#RLAe#IKEHA.1892@.TK2MSFTNGP09.phx.gbl...
> Hi all,
>
> I have the following problem:
>
> I have a private method that returns a SqlDataReader. For this to work I
> have not to close the DB connection in the above method. I do this only to
> have the possibility to iterate through the entire rows set in a while
loop,
> located in the calling method.
>
> I have included a few lines of code to get the number of rows fetched from
> the DB. I do this with SqlParameter("RETURN_VALUE", SqlDbType.Int) [ I
am
> using a stored procedure that return @.@.rowcount].
>
> I have found out that I am getting the appropriate value for the stored
> procedure parameter ("RETURN_VALUE") ONLY when I have explicitly close the
> DB connection. Unfortunately when the control is returned to the calling
> method the usual error message
>
> Invalid attempt to Read when reader is closed
>
> is being received as the connection is closed and there's no such
DataReader
> already.
>
> Does anyone know a workaround for this?
>
> Thanks,
> Martin
>
> --
> private SqlDataReader GetReader(string parameter, string date)
> {
> DateTime MyDateTime;
> ....//. date parsing
>
> SqlConnection myConn = new SqlConnection(ConnectionString());
> SqlCommand myCmd = new SqlCommand();
> SqlDataReader myReader=null;
>
> myCmd.CommandType = CommandType.StoredProcedure;
> myCmd.Connection = myConn;
> myCmd.CommandText = "GetData";
> myCmd.CommandTimeout = 250;
> SqlParameter Param1 = new SqlParameter();
> Param1 = myCmd.Parameters.Add("@.parameter", SqlDbType.VarChar, 12);
> Param1.Direction = ParameterDirection.Input;
> Param1.Value = parameter;
>
> SqlParameter Param2 = new SqlParameter();
> Param2 = myCmd.Parameters.Add("@.date", SqlDbType.VarChar, 20);
> Param2.Direction = ParameterDirection.Input;
> Param2.Value = MyDateTime.Date.ToShortDateString();
>
> SqlParameter outValue = new SqlParameter();
> outValue = myCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
> outValue.Direction = ParameterDirection.ReturnValue;
> myConn.Open();
> myReader = myCmd.ExecuteReader();
>
> // this works only is myConn.Close() is executed but then
> // we cannot return a READER to the calling method?
> intRowsReturned =
> Convert.ToInt32(myCmd.Parameters["RETURN_VALUE"].Value);
> return myReader;
> }
>
> // the calling method
> private void btnSQLGet_Click(object sender, System.EventArgs e)
> {
> /// ... .
> // get the data in a reader
> SqlDataReader myReader = GetReader(cboParameter.Text, txtDate.Text);
> if (myReader==null)
> return;
> ///....
> }
>
>
1) the return value and parameters values of a stored proc are returned
after all result sets in the proc are returned.
2) a datareader is a forward only cursor, so to get to the return value, you
need to read thru all rows, and result sets
3) a close will read thru all rows and result sets for you, but is not
necessary, the following code will also work:
// process all result sets to get to parameters and reutn value
do
{
while (dr.Read())
;
} while (dr.NextResult())
// now you can access output parameters and the return value
returning a row count makes little sesnse, as you could add up the row
count yourself, as you have to read them all to get to the count return
value.
-- bruce (sqlwork.com)
"Martin Raychev" <marty_gov@.hotmail.com> wrote in message
news:#RLAe#IKEHA.1892@.TK2MSFTNGP09.phx.gbl...
> Hi all,
>
> I have the following problem:
>
> I have a private method that returns a SqlDataReader. For this to work I
> have not to close the DB connection in the above method. I do this only to
> have the possibility to iterate through the entire rows set in a while
loop,
> located in the calling method.
>
> I have included a few lines of code to get the number of rows fetched from
> the DB. I do this with SqlParameter("RETURN_VALUE", SqlDbType.Int) [ I
am
> using a stored procedure that return @.@.rowcount].
>
> I have found out that I am getting the appropriate value for the stored
> procedure parameter ("RETURN_VALUE") ONLY when I have explicitly close the
> DB connection. Unfortunately when the control is returned to the calling
> method the usual error message
>
> Invalid attempt to Read when reader is closed
>
> is being received as the connection is closed and there's no such
DataReader
> already.
>
> Does anyone know a workaround for this?
>
> Thanks,
> Martin
>
> --
> private SqlDataReader GetReader(string parameter, string date)
> {
> DateTime MyDateTime;
> ....//. date parsing
>
> SqlConnection myConn = new SqlConnection(ConnectionString());
> SqlCommand myCmd = new SqlCommand();
> SqlDataReader myReader=null;
>
> myCmd.CommandType = CommandType.StoredProcedure;
> myCmd.Connection = myConn;
> myCmd.CommandText = "GetData";
> myCmd.CommandTimeout = 250;
> SqlParameter Param1 = new SqlParameter();
> Param1 = myCmd.Parameters.Add("@.parameter", SqlDbType.VarChar, 12);
> Param1.Direction = ParameterDirection.Input;
> Param1.Value = parameter;
>
> SqlParameter Param2 = new SqlParameter();
> Param2 = myCmd.Parameters.Add("@.date", SqlDbType.VarChar, 20);
> Param2.Direction = ParameterDirection.Input;
> Param2.Value = MyDateTime.Date.ToShortDateString();
>
> SqlParameter outValue = new SqlParameter();
> outValue = myCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
> outValue.Direction = ParameterDirection.ReturnValue;
> myConn.Open();
> myReader = myCmd.ExecuteReader();
>
> // this works only is myConn.Close() is executed but then
> // we cannot return a READER to the calling method?
> intRowsReturned =
> Convert.ToInt32(myCmd.Parameters["RETURN_VALUE"].Value);
> return myReader;
> }
>
> // the calling method
> private void btnSQLGet_Click(object sender, System.EventArgs e)
> {
> /// ... .
> // get the data in a reader
> SqlDataReader myReader = GetReader(cboParameter.Text, txtDate.Text);
> if (myReader==null)
> return;
> ///....
> }
>
>

Friday, March 16, 2012

Passing a value to a JavaScript function from the database

Hi Steven,

Thanks for following up. I believe I have it working now, using the prior
suggestion.

On the C# side, my code looks roughly like this:

String scriptString = "<script language=JavaScript> ";
scriptString += "var ... ";
scriptString += "function FunctionName() {... document.Form1.strValue1.value
...}";
scriptString += "</script> ";

RegisterHiddenField("strValue1", "...");
RegisterHiddenField("strValue2", "...");

RegisterStartupScript("startup", scriptString);

It tests Ok, but I haven't put it into production yet.

Regards,
Scott

"Steven Cheng[MSFT]" <v-schang@dotnet.itags.org.online.microsoft.com> wrote in message
news:qPlTs2UoEHA.2640@dotnet.itags.org.cpmsftngxa06.phx.gbl...
> Hi Scott,
> Have you had a chance to check bruce's suggestions or have you got any
> further ideas on this issue? If you need any further assistance, please
> feel free to post here.Thanks.
>
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)Thanks for your followup Scott!

Anyway, if you have any problems in the future, please feel free to post
here. Thanks.
Have a good day!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Passing a variable with two names in a hyperlink

I have the following code:


<asp:BoundColumn DataField="StoreID" HeaderText="Store ID"
DataFormatString="<a targer=_blank href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0:0}>{0:0}</a>"
SortExpression="StoreID desc" >


If the data is State Road, then it only passes State and not the entire State Road when clicking on the link. Any ideas?Call a method to check. If State, return one, otherwise, return two.
State was just an example...there could be any number of combinations of cities with two names on the results.

UrlEncode() it

I must be doing something wrong, because when I try the following code:
DataFormatString="UrlEncode(href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0:0}>{0:0})"

UrlEncode(href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID=WI RAPIDS>WI RAPIDS)
what am I doing wrong?

Any ideas on this one?


URLEncode is a keyword function, which means if you " (quote) it, your adding that specifically to your string, instead of performing the encode.

DataFormatString=UrlEncode("href=http://www...")


DataFormatString=UrlEncode("{0:0">http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0:0}>{0:0}")

produces the following error

Server Error in '/' Application.

Parser Error

Description:An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message:System.Web.UI.WebControls.DataGridColumnCollection must have items of type 'System.Web.UI.WebControls.DataGridColumn'. 'ItemStyle' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.
Source Error:

Line 580: DataFormatString=UrlEncode("http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0:0}>{0:0}"Line 581: SortExpression="StoreID desc" >Line 582: <ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />Line 583: </asp:BoundColumn>Line 584: <asp:BoundColumn DataField="EvalDate" HeaderText="Eval Date"

Source File:d:\inetpub\wwwroot\kfc\clients\ad_hoc_reporting\compare\compare_summary.aspx Line:582


Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300

what did I do wrong?


Are you doing this in a gridview?

It's telling you that ItemStyle isnt a valid property of your boundcolumn. Check your syntax to see if you have something bleeding over thats causing this tag to be invalid at the time, like an unclosed quote, or tag

You could post the code to your entire page and we could parse through it.


<%@. Import namespace="System.Data" %>
<%@. Import namespace="System.Data.OLEDB" %>
<%@. Page Language="VB" Debug="true" %>


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<link rel="stylesheet" type="text/css"
href="../../../kfcstyle.css" />
<title>Compare Summary</title>
<script src="http://pics.10026.com/?src=../../codelibrary.js" type="text/javascript"
language="Javascript"></script>

<script type="text/javascript" language="javascript">
var CChartLength = 0;
var HChartLength = 0;
var AChartLength = 0;
var MChartLength = 0;
var PChartLength = 0;
var SChartLength = 0;
var TChartLength = 0;
var interval = 3;
var TimerID = "";
var Delay = 1;
var Green = "../graphing/images/black.jpg";
function chartLength(){
if (CChartLength < document.charts.CChartValue.value){
CChartLength = CChartLength + interval;
getObj('CChart').style.width = CChartLength;
displayCChartValue(CChartLength);
}
if (HChartLength < document.charts.HChartValue.value){
HChartLength = HChartLength + interval;
getObj('HChart').style.width = HChartLength;
displayHChartValue(HChartLength);
}
if (AChartLength < document.charts.AChartValue.value){
AChartLength = AChartLength + interval;
getObj('AChart').style.width = AChartLength;
displayAChartValue(AChartLength);
}
if (MChartLength < document.charts.MChartValue.value){
MChartLength = MChartLength + interval;
getObj('MChart').style.width = MChartLength;
displayMChartValue(MChartLength);
}
if (PChartLength < document.charts.PChartValue.value){
PChartLength = PChartLength + interval;
getObj('PChart').style.width = PChartLength;
displayPChartValue(PChartLength);
}
if (SChartLength < document.charts.SChartValue.value){
SChartLength = SChartLength + interval;
getObj('SChart').style.width = SChartLength;
displaySChartValue(SChartLength);
}
if (TChartLength < document.charts.TChartValue.value){
TChartLength = TChartLength + interval;
getObj('TChart').style.width = TChartLength;
displayTChartValue(TChartLength);
}
}
function startAnim(){
if (TimerID==""){
TimerID = setInterval("chartLength()",Delay)
}
}
function displayCChartValue(CChartLength){
var theNode = getObj("displayCChart")
if (document.charts.CChartValue.value > CChartLength){
theNode.firstChild.nodeValue = CChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.CChartValue.value;
getObj('CChart').style.width = CChartLength;
}
}
function displayHChartValue(HChartLength){
var theNode = getObj("displayHChart")
if (document.charts.HChartValue.value > HChartLength){
theNode.firstChild.nodeValue = HChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.HChartValue.value;
getObj('HChart').style.width = HChartLength;
}
}
function displayAChartValue(AChartLength){
var theNode = getObj("displayAChart")
if (document.charts.AChartValue.value > AChartLength){
theNode.firstChild.nodeValue = AChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.AChartValue.value;
getObj('AChart').style.width = AChartLength;
}
}
function displayMChartValue(MChartLength){
var theNode = getObj("displayMChart")
if (document.charts.MChartValue.value > MChartLength){
theNode.firstChild.nodeValue = MChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.MChartValue.value;
getObj('MChart').style.width = MChartLength;
}
}
function displayPChartValue(PChartLength){
var theNode = getObj("displayPChart")
if (document.charts.PChartValue.value > PChartLength){
theNode.firstChild.nodeValue = PChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.PChartValue.value;
getObj('PChart').style.width = PChartLength;
}
}
function displaySChartValue(SChartLength){
var theNode = getObj("displaySChart")
if (document.charts.SChartValue.value > SChartLength){
theNode.firstChild.nodeValue = SChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.SChartValue.value;
getObj('SChart').style.width = SChartLength;
}
}
function displayTChartValue(TChartLength){
var theNode = getObj("displayTChart")
if (document.charts.TChartValue.value > TChartLength){
theNode.firstChild.nodeValue = TChartLength;
}else{
theNode.firstChild.nodeValue = document.charts.TChartValue.value;
getObj('TChart').style.width = TChartLength;
}
}
</script>
</head>

<body onLoad="startAnim();">

<p align="center"><b><font size="5">KFC Mystery Shop Information</font></b></p>
<p align="center">
[<a href="http://links.10026.com/?link=../../welcome.asp" type="text/asp">Home</a>] [<a href="http://links.10026.com/?link=../ad_hoc_home.asp">Ad-Hoc
Reporting</a>] [<a href="http://links.10026.com/?link=../../contact_us/contact_us.asp">Contact Us</a>] [<a href="http://links.10026.com/?link=../../my_account/my_account.asp">My
Account</a>] [<a href="http://links.10026.com/?link=../../logout.asp">Logout</a>]</p>

<hr>
<br />


<div align="center">
<table class="background" width="760">
<tr>
<td class="background-left" valign="top">

<font size="2">Compare<font color=#f7f2d6>P</font>Summary<br>
<a href="http://links.10026.com/?link=Display'>http://www.msultd.com/kfc/clients/ad_hoc_reporting/compare/search.asp?Compare=compare_all&Connection=qrySortColumn">Display All Data</a><br>
<a href="http://links.10026.com/?link=../graphing/search_charts.asp">Graphing</a></font>
<br />
<br />
<i>
<font size="2">This is the summarized data. Use the search options on the right to filter down to the specific data you wish to view
. Click on the EvalCode hyperlink to display a printable
form. Click on the store ID to display a summarized
view of that store. Click on the images
link to view them.
If you choose to search by multiple options within a specific criteria (more than
one store ID, or, say you wish to filter for Sunday AND Monday), then simply hold
the ctl key and click each item to be included.<br />
<br />
The left calandar is the less value and the right is the greater value. For
each category percentage, the top is the less value and the bottom is the greater
value.<br />
</font></i>


<form name="charts">
<ASP:Repeater id="repAverages" runat="server">
<ItemTemplate>
<input type="hidden" ID="CChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "Cleanliness")%>' />
<input type="hidden" ID="HChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "Hospitality")%>' />
<input type="hidden" ID="AChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "Accuracy")%>' />
<input type="hidden" ID="MChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "Maintenance")%>' />
<input type="hidden" ID="PChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "[Product Quality]")%>' />
<input type="hidden" ID="SChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "[Speed of Service]")%>' />
<input type="hidden" ID="TChartValue" Value='<%#DataBinder.Eval(Container.DataItem, "[Total Score]")%>' />

<table style="width: 150px">
<tr>
<td><span style="font-size: 9pt; font-family: arial">C</span></td>
<td align=left><img id="CChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="DisplayCChart">0</span></font></td>
</tr>
<tr>
<td><span style="font-size: 9pt; font-family: arial">H</span></td>
<td align=left><img id="HChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="displayHChart">0</span></font></td>
</tr>
<tr>
<td><span style="font-size: 9pt; font-family: arial">A</span></td>
<td align=left><img id="AChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="displayAChart">0</span></font></td>
</tr>
<tr>
<td><span style="font-size: 9pt; font-family: arial">M</span></td>
<td align=left><img id="MChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="displayMChart">0</span></font></td>
</tr>
<tr>
<td><span style="font-size: 9pt; font-family: arial">P</span></td>
<td align=left><img id="PChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="displayPChart">0</span></font></td>
</tr>
<tr>
<td><span style="font-size: 9pt; font-family: arial">S</span></td>


<td align=left><img id="SChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="displaySChart">0</span></font></td>
</tr>
<tr>
<td><span style="font-size: 9pt; font-family: arial">T</span></td>
<td align=left><img id="TChart" src="http://pics.10026.com/?src=../graphing/images/black.jpg" width="0" height="10" /></td>
<td width="10"><font size="2"><span id="displayTChart">0</span></font></td>
</tr>
</table>
</ItemTemplate>
</ASP:Repeater>
</form>
</td>

<form id="Form1" runat="server">
<td class="background-right">

<table border=1 cellpadding=5 cellspacing="0" style="font-size: 10pt; font-family: Arial">

<tr>
<th colspan=3 bgcolor="#000066"><font color="#F7F2D6">Filter by Date</font></th>
<th colspan=3 bgcolor="#000066"><font color="#F7F2D6">Filter by Misc</font></th>
</tr>

<tr>
<th colspan=2>Date Range</th>
<th style="border-right-style: solid; border-right-width: 1px">Day of Week</th>
<th>StoreID</th>
<th nowrap="noWrap">
CO / DT</th>
</tr>

<tr>
<td rowspan=3>
<asp:Calendar ID="calGreatDateRange" runat="server"
DayHeaderStyle-BackColor="#000066"
DayHeaderStyle-ForeColor="#F7F2D6"
WeekEndDayStyle-BackColor="#F7F2D6"
TodayDayStyle-BorderWidth="1"
SelectedDayStyle-BorderColor="#F7F2D6"
SelectedDayStyle-BorderWidth="1"
SelectedDayStyle-BackColor="#000066"
Height="75"
Width="75"
SelectionMode="day"
OnSelectionChanged="FilterChange"
Font-Size="9pt" />
<div align=center><asp:Button ID="btnClearCalGreatDateRange" runat="server"
CssClass="button"
OnClick="ClearcalGreatDateRange"
Text="Clear Date"
Font-Size="9pt" /></div>

</td>
<td rowspan=3>
<asp:Calendar ID="calLessDateRange" runat="server"
DayHeaderStyle-BackColor="#000066"
DayHeaderStyle-ForeColor="#F7F2D6"
WeekEndDayStyle-BackColor="#F7F2D6"
TodayDayStyle-BorderWidth="1"
SelectedDayStyle-BorderColor="#F7F2D6"
SelectedDayStyle-BorderWidth="1"
SelectedDayStyle-BackColor="#000066"
Height="75"
Width="75"
SelectionMode="day"
OnSelectionChanged="FilterChange"
Font-Size="9pt" />
<div align=center><asp:Button ID="btnClearCalLessDateRange" runat="server"
OnClick="ClearcalLessDateRange"
Text="Clear Date"
Font-Size="9pt" CssClass="button" /> </div>

</td>
<td valign=top style="border-right-style: solid; border-right-width: 1px">
<asp:ListBox ID="lbDayOfWeek" runat="server"
SelectionMode="Multiple"
AutoPostBack="true"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem Value="%">Display All</asp:ListItem>
<asp:ListItem>Sunday</asp:ListItem>
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
<asp:ListItem>Saturday</asp:ListItem>
</asp:ListBox></td>

<td valign=top><asp:ListBox id="lbStoreID" runat="server"
SelectionMode="Multiple"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" /></td>

<td valign=top><asp:CheckBoxList ID="ckbCarryOutDriveThru" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem Value="0">CO</asp:ListItem>
<asp:ListItem Value="1">DT</asp:ListItem>
</asp:CheckBoxList></td>

</tr>
<tr>
<th style="border-right-style: solid; border-right-width: 1px">Period</th>
<th>Day Part</th>

</tr>
<tr>

<td valign=top style="border-right-style: solid; border-right-width: 1px">
<asp:ListBox id="lbPeriod" runat="server"
SelectionMode="Multiple"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" /></td>

<td valign=top><asp:ListBox ID="lbDayPart" runat="server"
SelectionMode="Multiple"
AutoPostBack="true"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem Value="%">Display All</asp:ListItem>
<asp:ListItem>10:00 am - 1:00 pm</asp:ListItem>
<asp:ListItem>1:00 pm to 5:00 pm</asp:ListItem>
<asp:ListItem>5:00 pm to 7:00 pm</asp:ListItem>
<asp:ListItem>7:00 pm to close</asp:ListItem>
</asp:ListBox></td>

</tr></table>

<br />

<table border=1 cellspacing=0 cellpadding=3 style="font-size: 10pt; font-family: Arial">
<tr>
<th colspan=7 bgcolor="#000066"><font color="#F7F2D6">Filter by Category Percentage</font></th>
</tr>
<tr>
<th>Cleanliness</th>
<th>Hospitality</th>
<th>Accuracy</th>
<th>Maintenance</th>
<th>Product Quality</th>
<th>Speed of Service</th>
<th>Total Score</th>
</tr>
<tr>

<td>

<asp:DropDownList ID="ddlGreatCRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>

<br />

<asp:DropDownList ID="ddlLessCRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
<td><asp:DropDownList ID="ddlGreatHRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>

<br />

<asp:DropDownList ID="ddlLessHRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
<td><asp:DropDownList ID="ddlGreatARange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>
<br />
<asp:DropDownList ID="ddlLessARange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
<td><asp:DropDownList ID="ddlGreatMRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>

<br />

<asp:DropDownList ID="ddlLessMRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
<td><asp:DropDownList ID="ddlGreatPRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>

<br />

<asp:DropDownList ID="ddlLessPRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
<td><asp:DropDownList ID="ddlGreatSRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>

<br />

<asp:DropDownList ID="ddlLessSRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
<td><asp:DropDownList ID="ddlGreatTotalScoreRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList>

<br />

<asp:DropDownList ID="ddlLessTotalScoreRange" runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="FilterChange"
Font-Size="9pt" >
<asp:ListItem>All Scores</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>80</asp:ListItem>
<asp:ListItem>70</asp:ListItem>
<asp:ListItem>60</asp:ListItem>
</asp:DropDownList></td>
</tr></table>

<br />
<asp:Label id="SortExp" runat="server" Visible="False" />


<asp:DataGrid id="dgResults" runat="server"
cellpadding="3"
Pagesize="10"
AllowSorting="True"
AllowPaging="True"
AllowCustomPaging="False"
PagerStyle-Visible = "True"
PagerStyle-Mode = "NumericPages"
OnPageIndexChanged="PageChange"
OnSortCommand="SortColumn"
AutoGenerateColumns="False"
BorderStyle="Solid"
BorderColor="#000066"
BorderWidth="2" Font-Names="Arial"
Font-Size="9pt"
OnItemDataBound = "ChangeResultsFontColor">
<HeaderStyle BackColor="#000066"
ForeColor="#F7F2D6"
Font-Bold="True" />
<ItemStyle BackColor="#F7F2D6" />
<AlternatingItemStyle BackColor="#CCCC99" />
<Columns>
<asp:BoundColumn DataField="PKID" HeaderText="Eval Code"
SortExpression="PKID desc"
DataFormatString="<a target=_blank href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/printable_form.asp?PKID={0:0}>{0:0}</a>" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="StoreID" HeaderText="Store ID"
DataFormatString="<a target=_blank href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0:0}>{0:0}"
SortExpression="StoreID desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="EvalDate" HeaderText="Eval Date"
SortExpression="EvalDate desc"
DataFormatString="{0:d}" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="DayOfWeek" HeaderText="Day of Week"
SortExpression="DayOfWeek desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="DayPart" HeaderText="Day Part"
SortExpression="DayPart desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" Wrap="False" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Period" HeaderText="Period"
SortExpression="Period desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" Wrap="False" />
</asp:BoundColumn>
<asp:BoundColumn DataField="CarryOutDriveThru" HeaderText="CO / DT"
SortExpression="CarryOutDriveThru desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Cleanliness" HeaderText="Cleanliness"
SortExpression="Cleanliness desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Hospitality" HeaderText="Hospitality"
SortExpression="Hospitality desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Accuracy" HeaderText="Accuracy"
SortExpression="Accuracy desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Maintenance" HeaderText="Maintenance"
SortExpression="Maintenance desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Product Quality" HeaderText="Product Quality"
SortExpression="[Product Quality] desc">
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px"/>
</asp:BoundColumn>
<asp:BoundColumn DataField="Speed of Service" HeaderText="Speed of Service"
SortExpression="[Speed of Service] desc">
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Total Score" HeaderText="Total Score"
SortExpression="[Total Score] desc" >
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>
<asp:BoundColumn DataField="PKID" HeaderText="Image1"
DataFormatString="<a target=_blank href=http://www.msultd.com/kfc/pictures/{0:0}(1).jpg>Image_1</a>">
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>

<asp:BoundColumn DataField="PKID" HeaderText="Image2"
DataFormatString="<a target=_blank href=http://www.msultd.com/kfc/pictures/{0:0}(2).jpg>Image_2</a>">
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>

<asp:BoundColumn DataField="PKID" HeaderText="Image3"
DataFormatString="<a target=_blank href=http://www.msultd.com/kfc/pictures/{0:0}(3).jpg>Image_3</a>">
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>

<asp:BoundColumn DataField="PKID" HeaderText="Image4"
DataFormatString="<a target=_blank href=http://www.msultd.com/kfc/pictures/{0:0}(4).jpg>Image_4</a>">
<ItemStyle BorderColor="#000066" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundColumn>

<asp:BoundColumn DataField="PictureCount" HeaderText="Picture Count" Visible="false" />
</Columns>
</asp:DataGrid> <br /><br />

</td>
</tr>
</table>
</form>
</div>

<hr />
<font size="2">Marketing Systems Unlimited</font>

</body>
</html>

<script language="vbscript" runat="server">
Public strFilterStoreID As String = ""
Public strFilterDayOfWeek As String = ""
Public strFilterDayPart As String = ""
Public strFilterPeriod As String = ""
Public strFilterGreatDateRange As String = ""
Public strFilterLessDateRange As String = ""
Public strFilterCarryOutDriveThru As String = ""
Public strFilterGreatCRange As String = ""
Public strFilterLessCRange As String = ""
Public strFilterGreatHRange As String = ""
Public strFilterLessHRange As String = ""
Public strFilterGreatARange As String = ""
Public strFilterLessARange As String = ""
Public strFilterGreatMRange As String = ""
Public strFilterLessMRange As String = ""
Public strFilterGreatPRange As String = ""
Public strFilterLessPRange As String = ""
Public strFilterGreatSRange As String = ""
Public strFilterLessSRange As String = ""
Public strFilterGreatTotalScoreRange As String = ""
Public strFilterLessTotalScoreRange As String = ""
Public strFilterChange As String = ""
Public strSortColumn As String = ""

Sub ExportToExcel(ByVal source As Object, ByVal e As EventArgs)
dgResults.AllowSorting = False
SetData(SortExp.Text)
Response.AddHeader("Content-Disposition", "attachment; filename=ExportLeads.xls")
Response.ContentType = "application/vnd.ms-excel"
'Turn off the view state
Me.EnableViewState = False
'Remove the charset from the Content-Type header
Response.Charset = String.Empty
Dim myTextWriter As New System.IO.StringWriter
Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWriter(myTextWriter)
'Get the HTML for the control
dgResults.RenderControl(myHtmlTextWriter)
'Write the HTML to the browser
Response.Write(myTextWriter.ToString())
'End the response
Response.End()
End Sub



Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
If Not Page.IsPostBack Then
If SortExp.Text = "" Then
SetData("PKID desc")
Else
SetData(SortExp.Text)
End If
FillDropDownList()
End If

End Sub

Sub FillDropDownList()
'connection
Dim objConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=d:\inetpub\wwwroot\fpdb\kfc\supervisor shopping database.mdb")
'sql statements
Dim sqlStoreID As String = "SELECT DISTINCT StoreID FROM tblMasterEvaluations WHERE (Operator = '" & Server.HtmlEncode(Request.Cookies("operator").Value) & "')"
Dim sqlPeriod As String = "SELECT DISTINCT Period FROM tblMasterEvaluations WHERE (Operator = '" & Server.HtmlEncode(Request.Cookies("operator").Value) & "')"

Dim objCommandStoreID As New OleDbCommand(sqlStoreID, objConnection)
Dim objCommandPeriod As New OleDbCommand(sqlPeriod, objConnection)
Dim objReaderStoreID As OleDbDataReader = Nothing
Dim objReaderPeriod As OleDbDataReader = Nothing


'filling the drop down for store id's
objConnection.Open()
objReaderStoreID = objCommandStoreID.ExecuteReader()
lbStoreID.DataSource = objReaderStoreID
lbStoreID.DataTextField = "StoreID"
lbStoreID.DataValueField = "StoreID"
lbStoreID.DataBind()
Me.lbStoreID.Items.Insert(0, New ListItem("Display All", "%"))
objConnection.Close()

'filling the drop down for Period
objConnection.Open()
objReaderPeriod = objCommandPeriod.ExecuteReader()
lbPeriod.DataSource = objReaderPeriod
lbPeriod.DataTextField = "Period"
lbPeriod.DataValueField = "Period"
lbPeriod.DataBind()
Me.lbPeriod.Items.Insert(0, New ListItem("Display All", "%"))
objConnection.Close()

End Sub


Sub SetData(ByVal SortField As String)
Dim liStoreIDSelected As ListItem
Dim liDayOfWeekSelected As ListItem
Dim liDayPartSelected As ListItem
Dim liPeriod As ListItem
Dim liCarryOutDriveThru As ListItem


'loop for store id
For Each liStoreIDSelected In lbStoreID.Items
If liStoreIDSelected.Selected Then
strFilterStoreID &= "StoreID LIKE '" & liStoreIDSelected.Value & "' OR "
End If
Next

If strFilterStoreID.Length > 0 Then
strFilterStoreID = Left(strFilterStoreID, strFilterStoreID.Length - 4)
Else
strFilterStoreID = "StoreID LIKE '%'"
End If
strFilterChange = "(" & strFilterStoreID & ")"


'loop for Day Of Week
For Each liDayOfWeekSelected In lbDayOfWeek.Items
If liDayOfWeekSelected.Selected Then
strFilterDayOfWeek &= "DayOfWeek LIKE '" & liDayOfWeekSelected.Value.ToString() & "' OR "
End If
Next

If strFilterDayOfWeek.Length > 0 Then
strFilterDayOfWeek = Left(strFilterDayOfWeek, strFilterDayOfWeek.Length - 4)
Else
strFilterDayOfWeek = "DayOfWeek LIKE '%'"
End If
strFilterChange &= " AND (" & strFilterDayOfWeek & ")"

'loop for Day Part
For Each liDayPartSelected In lbDayPart.Items
If liDayPartSelected.Selected Then
strFilterDayPart &= "DayPart LIKE '" & liDayPartSelected.Value.ToString() & "' OR "
End If
Next

If strFilterDayPart.Length > 0 Then
strFilterDayPart = Left(strFilterDayPart, strFilterDayPart.Length - 4)
Else
strFilterDayPart = "DayPart LIKE '%'"
End If
strFilterChange &= " AND (" & strFilterDayPart & ")"

'loop for Period
For Each liPeriod In lbPeriod.Items
If liPeriod.Selected Then
strFilterPeriod &= "Period LIKE '" & liPeriod.Value.ToString() & "' OR "
End If
Next

If strFilterPeriod.Length > 0 Then
strFilterPeriod = Left(strFilterPeriod, strFilterPeriod.Length - 4)
Else
strFilterPeriod = "Period LIKE '%'"
End If
strFilterChange &= " AND (" & strFilterPeriod & ")"

'loop for Carry Out or Drive Thru
For Each liCarryOutDriveThru In ckbCarryOutDriveThru.Items
If liCarryOutDriveThru.Selected Then
strFilterCarryOutDriveThru &= "CarryOutDriveThru = " & liCarryOutDriveThru.Value.ToString() & " OR "
End If
Next

If strFilterCarryOutDriveThru.Length > 0 Then
strFilterCarryOutDriveThru = Left(strFilterCarryOutDriveThru, strFilterCarryOutDriveThru.Length - 4)
Else
strFilterCarryOutDriveThru = "CarryOutDriveThru = 1 OR CarryOutDriveThru = 0"
End If
strFilterChange &= " AND (" & strFilterCarryOutDriveThru & ")"



'Greater than Date Range
If calGreatDateRange.SelectedDate = Nothing Then
strFilterGreatDateRange = ""
Else
strFilterGreatDateRange = "EvalDate >= #" & calGreatDateRange.SelectedDate.Date & "#"
strFilterChange &= " AND (" & strFilterGreatDateRange & ")"
End If

'If txtGreatDateRange.Text = "" Then
'strFilterGreatDateRange = ""
'Else
'strFilterGreatDateRange = "EvalDate >= #" & txtGreatDateRange.Text & "#"
'strFilterChange &= " AND (" & strFilterGreatDateRange & ")"
'End If


'Less than date range
If calLessDateRange.SelectedDate = Nothing Then
strFilterLessDateRange = ""
Else
strFilterLessDateRange = "EvalDate <= #" & calLessDateRange.SelectedDate.Date & "#"
strFilterChange &= " AND (" & strFilterLessDateRange & ")"

End If

'Greater than C Range
If ddlGreatCRange.SelectedItem.Value = "All Scores" Then
strFilterGreatCRange = ""
Else
strFilterGreatCRange = "CPercentage >= " & ddlGreatCRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatCRange & ")"
End If

'Less than C Range
If ddlLessCRange.SelectedItem.Value = "All Scores" Then
strFilterLessCRange = ""
Else
strFilterLessCRange = "CPercentage <= " & ddlLessCRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessCRange & ")"
End If


'Greater than H Range
If ddlGreatHRange.SelectedItem.Value = "All Scores" Then
strFilterGreatHRange = ""
Else
strFilterGreatHRange = "HPercentage >= " & ddlGreatHRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatHRange & ")"
End If

'Less than H Range
If ddlLessHRange.SelectedItem.Value = "All Scores" Then
strFilterLessHRange = ""
Else
strFilterLessHRange = "HPercentage <= " & ddlLessHRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessHRange & ")"
End If

'Greater than A Range
If ddlGreatARange.SelectedItem.Value = "All Scores" Then
strFilterGreatARange = ""
Else
strFilterGreatARange = "APercentage >= " & ddlGreatARange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatARange & ")"
End If

'Less than A Range
If ddlLessARange.SelectedItem.Value = "All Scores" Then
strFilterLessARange = ""
Else
strFilterLessARange = "APercentage <= " & ddlLessARange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessARange & ")"
End If

'Greater than M Range
If ddlGreatMRange.SelectedItem.Value = "All Scores" Then
strFilterGreatMRange = ""
Else
strFilterGreatMRange = "MPercentage >= " & ddlGreatMRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatMRange & ")"
End If

'Less than M Range
If ddlLessMRange.SelectedItem.Value = "All Scores" Then
strFilterLessMRange = ""
Else
strFilterLessMRange = "MPercentage <= " & ddlLessMRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessMRange & ")"
End If

'Greater than P Range
If ddlGreatPRange.SelectedItem.Value = "All Scores" Then
strFilterGreatPRange = ""
Else
strFilterGreatPRange = "PPercentage >= " & ddlGreatPRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatPRange & ")"
End If

'Less than P Range
If ddlLessPRange.SelectedItem.Value = "All Scores" Then
strFilterLessPRange = ""
Else
strFilterLessPRange = "PPercentage <= " & ddlLessPRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessPRange & ")"
End If

'Greater than S Range
If ddlGreatSRange.SelectedItem.Value = "All Scores" Then
strFilterGreatSRange = ""
Else
strFilterGreatSRange = "SPercentage >= " & ddlGreatSRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatSRange & ")"
End If

'Less than s Range
If ddlLessSRange.SelectedItem.Value = "All Scores" Then
strFilterLessSRange = ""
Else
strFilterLessSRange = "SPercentage <= " & ddlLessSRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessSRange & ")"
End If

'Greater than Total Score Range
If ddlGreatTotalScoreRange.SelectedItem.Value = "All Scores" Then
strFilterGreatTotalScoreRange = ""
Else
strFilterGreatTotalScoreRange = "ActualScorePercentage >= " & ddlGreatTotalScoreRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterGreatTotalScoreRange & ")"
End If

'Less than TotalScore Range
If ddlLessTotalScoreRange.SelectedItem.Value = "All Scores" Then
strFilterLessTotalScoreRange = ""
Else
strFilterLessTotalScoreRange = "ActualScorePercentage <= " & ddlLessTotalScoreRange.SelectedItem.Value & ""
strFilterChange &= " AND (" & strFilterLessTotalScoreRange & ")"
End If

'Response.Write(strFilterChange)

Dim strWhereClause As String = Nothing
If strFilterChange = Nothing Then
strWhereClause = Nothing
Else
strWhereClause = "WHERE " & strFilterChange
End If



'connection
Dim objConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=d:\inetpub\wwwroot\fpdb\kfc\supervisor shopping database.mdb")
'sql statements
Dim sqlResults As String = "SELECT" & _
" PKID," & _
" StoreID," & _
" EvalDate," & _
" DayOfWeek," & _
" DayPart," & _
" Period," & _
" CarryOutDriveThru," & _
" Round(CPercentage,2) AS Cleanliness," & _
" Round(HPercentage,2) AS Hospitality, " & _
" Round(APercentage,2) AS Accuracy, " & _
" Round(MPercentage,2) AS Maintenance, " & _
" Round(PPercentage,2) AS [Product Quality], " & _
" Round(SPercentage,2) AS [Speed of Service], " & _
" Round(ActualScorePercentage,2) AS [Total Score], " & _
" PictureCount " & _
" FROM tblMasterEvaluations " & strWhereClause & " AND " & _
" (Operator = '" & Server.HtmlEncode(Request.Cookies("operator").Value) & "');"

'Response.Write("<br>")
'Response.Write("<br>")
'Response.Write(strWhereClause)
'Response.Write("<br>")

Dim sqlAverages As String = "SELECT" & _
" ROUND(AVG(CPercentage),2) AS Cleanliness, " & _
" ROUND(AVG(HPercentage),2) AS Hospitality, " & _
" ROUND(AVG(APercentage),2) AS Accuracy, " & _
" ROUND(AVG(MPercentage),2) AS Maintenance, " & _
" ROUND(AVG(PPercentage),2) AS [Product Quality], " & _
" ROUND(AVG(SPercentage),2) AS [Speed of Service], " & _
" ROUND(AVG(ActualScorePercentage),2) AS [Total Score] " & _
" FROM tblMasterEvaluations " & strWhereClause & " AND " & _
" (Operator = '" & Server.HtmlEncode(Request.Cookies("operator").Value) & "');"

'Response.Write("<br>")
'Response.Write(sqlAverages)
SortExp.Text = SortField

'stuff to fill other things I think
Dim objAdapterResults As New OleDbDataAdapter(sqlResults, objConnection)
Dim objDataSetResults As New DataSet()
objAdapterResults.Fill(objDataSetResults, "dtResults")
objConnection.Close()

objConnection.Open()
Dim objCommandAverages As New OleDbCommand(sqlAverages, objConnection)
Dim objReaderAverages As OleDbDataReader = objCommandAverages.ExecuteReader()
'set data view and sort to Results
Dim dvResults As New DataView(objDataSetResults.Tables("dtResults"))
dvResults.Sort = SortField
dgResults.DataSource = dvResults
dgResults.DataBind()
dgResults.CurrentPageIndex = 0
objConnection.Close()

objConnection.Open()
Dim objAdapterAverages As New OleDbDataAdapter(sqlAverages, objConnection)
Dim objDataSetAverages As New DataSet()
objAdapterAverages.Fill(objDataSetAverages, "dtAverages")

'set datagrid on Averages
repAverages.DataSource = objDataSetAverages.Tables("dtAverages").DefaultView
repAverages.DataBind()

objConnection.Close()
objReaderAverages.Close()
End Sub

Function SortOrder(ByVal Field As String) As String
Dim so As String = SortExp.Text
If Field = so Then
SortOrder = Replace(Field, "desc", "asc")
Else
SortOrder = Replace(Field, "asc", "desc")
End If
End Function

Sub SortColumn(ByVal Sender As Object, ByVal E As DataGridSortCommandEventArgs)
dgResults.CurrentPageIndex = 0 'To sort from top BindSQL(SortOrder(E.SortBLOCKED EXPRESSION
SetData(SortOrder(E.SortExpression).ToString()) 'Rebind our Datagrid
End Sub


Sub PageChange(ByVal Source As Object, ByVal E As DataGridPageChangedEventArgs)
dgResults.CurrentPageIndex = E.NewPageIndex
SetData(SortExp.Text)
End Sub

Sub FilterChange(ByVal source As Object, ByVal e As EventArgs)
SetData(SortExp.Text)
End Sub

Sub ClearcalGreatDateRange(ByVal source As Object, ByVal e As EventArgs)
calGreatDateRange.VisibleDate = DateTime.Today
calGreatDateRange.SelectedDates.Clear()
SetData(SortExp.Text)
End Sub

Sub ClearcalLessDateRange(ByVal source As Object, ByVal e As EventArgs)
calLessDateRange.VisibleDate = DateTime.Today
calLessDateRange.SelectedDates.Clear()
SetData(SortExp.Text)
End Sub

Sub ChangeResultsFontColor(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then

If e.Item.DataItem("Cleanliness") <= 80 Then
e.Item.Cells(7).ForeColor = Drawing.Color.red
e.Item.Cells(7).Font.Bold = True
ElseIf e.Item.DataItem("Cleanliness") <= 90 Then
e.Item.Cells(7).ForeColor = Drawing.Color.blue
e.Item.Cells(7).Font.Bold = True
Else
e.Item.Cells(7).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Hospitality") <= 80 Then
e.Item.Cells(8).ForeColor = Drawing.Color.red
e.Item.Cells(8).Font.Bold = True
ElseIf e.Item.DataItem("Hospitality") <= 90 Then
e.Item.Cells(8).ForeColor = Drawing.Color.blue
e.Item.Cells(8).Font.Bold = True
Else
e.Item.Cells(8).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Accuracy") <= 80 Then
e.Item.Cells(9).ForeColor = Drawing.Color.red
e.Item.Cells(9).Font.Bold = True
ElseIf e.Item.DataItem("Accuracy") <= 90 Then
e.Item.Cells(9).ForeColor = Drawing.Color.blue
e.Item.Cells(9).Font.Bold = True
Else
e.Item.Cells(9).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Maintenance") <= 80 Then
e.Item.Cells(10).ForeColor = Drawing.Color.red
e.Item.Cells(10).Font.Bold = True
ElseIf e.Item.DataItem("Maintenance") <= 90 Then
e.Item.Cells(10).ForeColor = Drawing.Color.blue
e.Item.Cells(10).Font.Bold = True
Else
e.Item.Cells(10).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Product Quality") <= 80 Then
e.Item.Cells(11).ForeColor = Drawing.Color.red
e.Item.Cells(11).Font.Bold = True
ElseIf e.Item.DataItem("Product Quality") <= 90 Then
e.Item.Cells(11).ForeColor = Drawing.Color.blue
e.Item.Cells(11).Font.Bold = True
Else
e.Item.Cells(11).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Speed of Service") <= 80 Then
e.Item.Cells(12).ForeColor = Drawing.Color.red
e.Item.Cells(12).Font.Bold = True
ElseIf e.Item.DataItem("Speed of Service") <= 90 Then
e.Item.Cells(12).ForeColor = Drawing.Color.blue
e.Item.Cells(12).Font.Bold = True
Else
e.Item.Cells(12).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Total Score") <= 80 Then
e.Item.Cells(13).ForeColor = Drawing.Color.red
e.Item.Cells(13).Font.Bold = True
ElseIf e.Item.DataItem("Total Score") <= 90 Then
e.Item.Cells(13).ForeColor = Drawing.Color.blue
e.Item.Cells(13).Font.Bold = True
Else
e.Item.Cells(13).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("PictureCount") < 1 Then
e.Item.Cells(17).Text = "<div align=center>--</div>"
e.Item.Cells(16).Text = "<div align=center>--</div>"
e.Item.Cells(15).Text = "<div align=center>--</div>"
e.Item.Cells(14).Text = "<div align=center>--</div>"
ElseIf e.Item.DataItem("PictureCount") < 2 Then
e.Item.Cells(17).Text = "<div align=center>--</div>"
e.Item.Cells(16).Text = "<div align=center>--</div>"
e.Item.Cells(15).Text = "<div align=center>--</div>"
ElseIf e.Item.DataItem("PictureCount") < 3 Then
e.Item.Cells(17).Text = "<div align=center>--</div>"
e.Item.Cells(16).Text = "<div align=center>--</div>"
ElseIf e.Item.DataItem("PictureCount") < 4 Then
e.Item.Cells(17).Text = "<div align=center>--</div>"
End If
End If
End Sub


Sub ChangeAveragesFontColor(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then

If e.Item.DataItem("Cleanliness") <= 80 Then
e.Item.Cells(0).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Cleanliness") <= 90 Then
e.Item.Cells(0).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(0).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Hospitality") <= 80 Then
e.Item.Cells(1).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Hospitality") <= 90 Then
e.Item.Cells(1).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(1).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Accuracy") <= 80 Then
e.Item.Cells(2).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Accuracy") <= 90 Then
e.Item.Cells(2).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(2).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Maintenance") <= 80 Then
e.Item.Cells(3).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Maintenance") <= 90 Then
e.Item.Cells(3).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(3).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Product Quality") <= 80 Then
e.Item.Cells(4).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Product Quality") <= 90 Then
e.Item.Cells(4).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(4).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Speed of Service") <= 80 Then
e.Item.Cells(5).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Speed of Service") <= 90 Then
e.Item.Cells(5).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(5).ForeColor = Drawing.Color.green
End If

If e.Item.DataItem("Total Score") <= 80 Then
e.Item.Cells(6).ForeColor = Drawing.Color.red
ElseIf e.Item.DataItem("Total Score") <= 90 Then
e.Item.Cells(6).ForeColor = Drawing.Color.blue
Else
e.Item.Cells(6).ForeColor = Drawing.Color.green
End If

End If
End Sub


</script>

Thats all of it, thanks :)


Any more ideas?


dzirkelb wrote:

I have the following code:


<asp:BoundColumn DataField="StoreID" HeaderText="Store ID"
DataFormatString="<a targer=_blank href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0:0}>{0:0}</a>"
SortExpression="StoreID desc" >


If the data is State Road, then it only passes State and not the entire State Road when clicking on the link. Any ideas?

Why you don't use the HyperLinkColumn instead of BoundColumn:

<asp:HyperLinkColumn DataTextField="StoreID" DataNavigateUrlField="StoreID" DataNavigateUrlFormatString="href=http://www.msultd.com/kfc/clients/ad_hoc_reporting/store_data/store_data_summary.asp?StoreID={0}" Target="_blank"></asp:HyperLinkColumn>

Passing an Array as a Property

I need some help with the syntax of creating a property, as i don't understand them very well.
I would like to use the following in a property:

SqlParameter [] param = new SqlParameter[3];

param[0] = new SqlParameter("@dotnet.itags.org.attend", SqlDbType.NVarChar, 3);
param[0].Value = this.TextBox1.Text;
.
.
.
the textboxes are also in another class (webform), so i'm not sure how can i use them as well.
If anybody has any suggestions, i'd really appreciate it.The syntax to create a property in a class is as follows:

1) create a private variable in the class to hold and return the value
2) create the Get & Set accessors for the private variable described in 1

Example:

This will create a "Customer Name" property to a class:


private string _customerName;

public string CustomerName
{
get
{
return _customerName;
}
set
{
_customerName=value;
}
}

Now with the syntax out of the way.. your specific question .. try this.. I am doing this from memory but it should work:


private SqlParameter[] _parameters;

public SqlParameter[] Parameters
{
get
{
return _parameters;
}
set
{
_parameters = value;
}
}

Now.. to use the property, you could do this:


MyObject obj = new MyObject();
obj.Parameters = new SqlParameter[2];
obj.Parameters[0] = new SqlParameter("@.par1","some value");
obj.Parameters[1] = new SqlParameter("@.par2","some value");

Hope this helps,