Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2013, 06:07 AM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 12
Thanks: 3
Thanked 0 Times in 0 Posts
Default Filtering data

I would like to filter data using Gridview like the examples on page 446/446. However I am missing the Parameter option in my VWD express. How can I transfer a calculated integer to this Where clause? Currently the only way that I can think of is using a cookie, somehow I think it could be done easier!

Erik
 
Old June 6th, 2013, 06:10 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Can you explain what you mean with " I am missing the Parameter option in my VWD express"? Your version should offer the same functionality as mine ;-)

Maybe you can post your working code and explain where the "calculated integer" comes from?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 6th, 2013, 06:12 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Also, check out this article: http://imar.spaanjaars.com/571/letti...t-45-web-forms

You can do similar stuff with your controls by handling the Selecting event: http://msdn.microsoft.com/en-us/libr...selecting.aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 6th, 2013, 06:26 AM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 12
Thanks: 3
Thanked 0 Times in 0 Posts
Default Thanks for this prompt reply

Thanks Imar:

When you click Where you get the wizzard for selction: Your book options are:Control, Cookie, Form, Parameter, Profile, Querystring and Session.
My wizzard has Control, Cookie, form, Profile, Query, Session and Route

So I am missing Parameter, which in your book says: you typically set the value through code..... I would like to use RV in my Where SQLDatasource

protected void CBKleur_SelectedIndexChanged(object sender, EventArgs e)
{
Double RV = 0;
for (int i = 1; i < CBKleur.Items.Count; i++)
{
if (CBKleur.Items[i].Selected) { RV += Math.Pow(2, (i - 1)); }
}
}

I will read your other link now :-)

Regards
Erik
 
Old June 6th, 2013, 07:36 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Ah, I thought you were using an EntityDataSource control. In that case, the correct link is:

http://msdn.microsoft.com/en-us/libr...selecting.aspx

The "Parameter" type maps to None in the drop down list. When you set up a new parameter and choose None, you get this in the Markup:

<asp:Parameter Name="ColumnName" Type="Int32" />

where ColumnName is the name of the column you associated with the Where clause.

You can then do something like this in the Code Behind (C#):

Code:
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
  e.Command.Parameters["@ColumnName"].Value = YourCalculatedValue;
}
Hope this helps.

Groeten,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 6th, 2013, 11:15 AM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 12
Thanks: 3
Thanked 0 Times in 0 Posts
Default half way there

thanks Imar, exactly what I needed. To finalize I am troubled why the value of RV is not transferred in below code between the 2 routines

Code:
public partial class Zoek : System.Web.UI.Page
{
    public Double RV;

    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

 
    protected void CBKleur_SelectedIndexChanged(object sender, EventArgs e)
    {
        // calculate value for where clause
        RV = 0;
        for (int i = 1; i < CBKleur.Items.Count; i++)
        {
            if (CBKleur.Items[i].Selected) { RV += Math.Pow(2, (i - 1)); }
        }
    }

    protected void SqlDataSource11_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        
        Int32 ColorSelected = Convert.ToInt32(RV);
        e.Command.Parameters["@ColorId"].Value = ColorSelected;
    }
}
best Regards,

Erik
 
Old June 6th, 2013, 11:21 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Maybe they fire in a different order than you expect? Also, since it's a page based value, RV goes out of scope after each page load (and postback).

I would abstract the logic to calculate RV to a separate method and call that from the Selecting event.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!




Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtering XML data aldwinenriquez XSLT 7 August 25th, 2008 03:24 AM
data filtering from combobox MAKO C# 4 June 1st, 2006 03:54 AM
Filtering User data donydog Classic ASP Databases 0 February 6th, 2006 09:33 PM
Need Help on Filtering duplicated data fanyin XSLT 2 November 4th, 2004 08:06 PM
Filtering data by code rodrigoss BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 June 23rd, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.