Blog ( Of Ryan Olshan)

Recent Posts

News

About Ryan Olshan

LinkedIn Profile

Follow Ryan via twitter

Join StrongTypes - Free Generics Help By Email
Join StrongTypes

Community Credit Winner

View my MVP profile

The posts on this weblog are provided "as is" with no warranties and confer no rights. The opinions expressed herin are my own personal opinions and do not represent my employer's view in any way.

Subscribe to Rolog via My AOL
Subscribe to Rolog via Bloglines


Subscribe to Rolog via Feedburner

Furl Rolog




Subscribe to Rolog via Newsburst


Subscribe to Rolog via Pluck

Add Rolog to Technorati Favorites




Thycotic Secret Server

Receive Email Updates


.NET Websites

  • => StrongTypes.com <=
  • Community Credit
  • DotNetCharity.com
  • DotNetSlackers
  • EasyListBox
  • LearnAsp.com
  • SystemNetMail.com
  • SystemWebMail.com

Blogroll

  • Alex Campbell
  • Carlos Magalhaes
  • Charles Carroll
  • Chris Taylor
  • Darren Neimke
  • David Betz
  • Eric Smith
  • Rob Caron
  • Rob Howard
  • Sam Gentile
  • Scott Guthrie
  • Scott Mitchell
  • Tess
  • Wesner Moise
  • Jason Alexander
  • Bill Ryan
  • Steve Smith
  • Sahil Malik
  • David Silverlight

Other Websites

  • 911 Pigeon Alert
  • Pacific Wildlife Project

Strong Coder Bloggers

  • Dean Fiala
  • Doug Nelson
  • Kevin Jones

Yahoo! Groups

  • => StrongTypes <=
  • AspNet2
  • AspNet20GridView
  • PayPalDevDotNet
  • RubyOnRails
  • VSTS

Sunday, January 22, 2006 - Posts

Do you moderate a Yahoo! group?
If you moderate or own a Yahoo! group, then you should be aware that there is currently a virus outbreak where somebody or several people are spamming groups by impersonating known email addresses that subscribe to the group, and even know enough to impersonate as unmoderated members. I have a feeling this is an inside job. Keep this blog post in mind before you jump the gun and ban and/or report a member who really didn't spam your group.
Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Jan 22 2006, 09:55 PM by Ryan Olshan | with 2 comment(s)
Filed under:
6 More Days...
Yeah. 6 more days until my Maryland trip. I'm going to attend a class being taught by Charles Carroll of LearnAsp.com . I'm really excited because I will get to meet the many programming nerds that I've met via IM and other means. Maryland here I come.
Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Jan 22 2006, 09:50 PM by Ryan Olshan | with 3 comment(s)
Filed under:
GridView without DataSourceControl DataSource

If you're like me and converting a .NET 1.1 application to 2.0, and aren't using a DataSourceControl DataSource just yet but need to enable sorting and paging, you might run into the following exceptions:

When changing the page:

The GridView 'GridViewID' fired event PageIndexChanging which wasn't handled.

When clicking a column name to sort the column:

The GridView 'GridViewID' fired event Sorting which wasn't handled.

As a result of not setting the DataSourceID property of the GridView to a DataSourceControl DataSource, you have to add event handlers for sorting and paging.

   

     < asp : GridView ID ="gridView" AllowPaging ="true" AllowSorting ="true "

         OnPageIndexChanging ="gridView_PageIndexChanging" OnSorting ="gridView_Sorting"

         runat ="server" />

 

    private string GridViewSortDirection

    {

        get { return ViewState[ "SortDirection" ] as string ?? "ASC" ; }

        set { ViewState[ "SortDirection" ] = value ; }

    }

 

    private string GridViewSortExpression

    {

        get { return ViewState[ "SortExpression" ] as string ?? string .Empty; }

        set { ViewState[ "SortExpression" ] = value ; }

    }

 

    private string GetSortDirection()

    {

        switch (GridViewSortDirection)

        {

            case "ASC" :

                GridViewSortDirection = "DESC" ;

                break ;

 

            case "DESC" :

                GridViewSortDirection = "ASC" ;

                break ;

        }

 

        return GridViewSortDirection;

    }

 

    protected void gridView_PageIndexChanging( object sender, GridViewPageEventArgs e)

    {

        gridView.DataSource = SortDataTable(gridView.DataSource as DataTable , true );

        gridView.PageIndex = e.NewPageIndex;

        gridView.DataBind();

    }

 

    protected DataView SortDataTable( DataTable dataTable, bool isPageIndexChanging)

    {

        if (dataTable != null )

        {

            DataView dataView = new DataView (dataTable);

            if (GridViewSortExpression != string .Empty)

            {

                if (isPageIndexChanging)

                {

                    dataView.Sort = string .Format( "{0} {1}" , GridViewSortExpression, GridViewSortDirection);

                }

                else

                {

                    dataView.Sort = string .Format( "{0} {1}" , GridViewSortExpression, GetSortDirection());

                }

            }

            return dataView;

        }

        else

        {

            return new DataView ();

        }

    }

 

    protected void gridView_Sorting( object sender, GridViewSortEventArgs e)

    {

        GridViewSortExpression = e.SortExpression;

        int pageIndex = gridView.PageIndex;

        gridView.DataSource = SortDataTable(gridView.DataSource as DataTable , false );

        gridView.DataBind();

        gridView.PageIndex = pageIndex;

    }

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Jan 22 2006, 01:26 PM by Ryan Olshan | with 35 comment(s) |
Filed under: ,
A better way to parse query string values for non-string data types

Occasionally, I've glanced at the TryParse method in IntelliSense, but never gave it a test run. TryParse is actually pretty cool. It will try to parse a string and see if it can convert it to a specified data type. This is perfect for query strings as you don't have to mess with testing for null values before either parsing or converting the query string to a data type and also eliminates any runtime errors that may be thrown and/or having to catch them.

string  booleanQueryString = Request.QueryString[ "SomeBoolean" ];
string  doubleQueryString = Request.QueryString[ "SomeDouble" ];
string  integerQueryString = Request.QueryString[ "SomeInteger" ];

double doubleValue;
int
integerValue;
bool booleanValue, booleanParseValue, doubleParseValue, integerParseValue;

booleanParseValue = bool .TryParse(booleanQueryString, booleanValue);
doubleParseValue = double .TryParse(doubleQueryString, doubleValue);
integerParseValue = int .TryParse(integerQueryString, integerValue);

if (booleanParseValue)
{
    // Do something
}

if (doubleParseValue)
{
    // Do something
}

if (integerParseValue)
{
    // Do something
}

Share this post: | bookmark it! | digg it! | reddit! | kick it! | live it!
Posted: Jan 22 2006, 01:10 PM by Ryan Olshan | with no comments
Filed under:
More Posts