Wrox Programmer Forums
|
Book: Wrox's Visual C# 2005 Express Edition Starter Kit
This is the forum to discuss the Wrox book Wrox's Visual C# 2005 Express Edition Starter Kit by F. Scott Barker; ISBN: 9780764589553
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Book: Wrox's Visual C# 2005 Express Edition Starter Kit 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 May 14th, 2007, 02:05 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combo box dropped down don't work proper

Hi,

I'm using combo box with keydown event and at any key down i'm using
combo.DroppedDown = true;
but when combo text is empty,its giving exception that "Invalid argument "0". Pls can anybody help me to find out solution.


 
Old May 28th, 2007, 07:08 AM
Registered User
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sandip.mis Send a message via Yahoo to sandip.mis
Default

using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    public String ConStr;
    SqlConnection cn;
    SqlCommand cm;
    SqlDataAdapter da;
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CatBind();
                   }
    }
    protected void CatBind()
    {
        ConStr = System.Configuration.ConfigurationManager.AppSetti ngs["constring"].ToString();
        cn = new SqlConnection(ConStr);
        cm=new SqlCommand("select * from Category",cn);
        da = new SqlDataAdapter(cm);
        da.Fill(ds);

        DrpCat.DataValueField = "CatId";
        DrpCat.DataTextField = "CatName";
        DrpCat.DataSource = ds;
        DrpCat.DataBind();
        DrpCat.Items.Insert(0, new ListItem("---Select---", "0"));

    }
    protected void ProBind(string id)
    {
        DrpPro.Items.Clear();
        ConStr = System.Configuration.ConfigurationManager.AppSetti ngs["constring"].ToString();
        cn = new SqlConnection(ConStr);
        cm = new SqlCommand("ProList", cn);
        cm.CommandType = CommandType.StoredProcedure;
        cm.Parameters.Add(new SqlParameter("@proid", SqlDbType.Int, 4, "ProId"));
        cm.Parameters[0].Value = Convert.ToInt32(id);
        da = new SqlDataAdapter(cm);
        da.Fill(ds);
        DrpPro.DataValueField = "ProId";
        DrpPro.DataTextField = "ProName";
        DrpPro.DataSource = ds;
        DrpPro.DataBind();
        DrpPro.Items.Insert(0, new ListItem("---Select---", "0"));

    }
    protected void DrpCat_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DrpCat.SelectedValue !="0")
        {
            ProBind(DrpCat.SelectedValue.ToString());
        }
    }



ProList Stored Procedure


ALTER PROCEDURE dbo.ProList
    @proid int=5
AS
    if @proid<>0
        begin
            select * from Product where CatId=@proid
        end
        else
        begin
            select * from Information
         end
    RETURN




Sandip





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
combo box doesnt work in IE7 but Firefox mamuco Classic ASP Components 1 June 4th, 2007 10:10 AM
Combo box can not work with dynamic Range dahlia492 Excel VBA 1 November 20th, 2006 12:43 PM
Access combo box does not work with SQL Server jerryk Access 3 July 14th, 2006 03:30 PM





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