Click here to Skip to main content
15,889,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to create a dropdownlist when an item is selected the user is redirected to another page and content about the item is displayed, all of this is done with stored procedures, but it does not seem to pass parameters to the stored procedure. I know the paramater is not passing but I don't know ehy not.
error:
Procedure or Function 'GetWidth' expects parameter '@WidthID', which was not supplied.
Can anyone help please?

C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string widthId =
            Server.UrlEncode(form.SelectedValue.ToString());
       
        Response.Redirect(Link.ToWidth(widthId));
    }


C#
private static string BuildAbsolute(string relativeUri)
    {
            // get current uri
        Uri uri = HttpContext.Current.Request.Url;
            // build absolute path
        string app = HttpContext.Current.Request.ApplicationPath;
        if (!app.EndsWith("/")) app += "/";
        relativeUri = relativeUri.TrimStart('/');
            // return the absolute path
        return HttpUtility.UrlPathEncode(
            String.Format("http://{0}:{1}{2}{3}",
            uri.Host, uri.Port, app, relativeUri));
    }
        // generate a width URL
    public static string ToWidth(string widthId)
    {
        return BuildAbsolute(String.Format("WidthAdmin.aspx?Width={0}", widthId));
    }


This is the receiving page, maybe I'm not calling it correctly, cause if I don't populate the GridView I get no errors

C#
protected void Page_Load(object sender, EventArgs e)
    {
            // load the grid only the first time the page is loaded
        if (!Page.IsPostBack)
        {
                // load the department grid
            BindGrid();
        }
    }
        // populate the grid view with data
    private void BindGrid()
    {
        string widthId =
            Server.UrlDecode(Request.QueryString["WidthID"]);
            // get a DataTable object containing the catalog departments
        grid.DataSource = CatalogAccess.GetWidth(widthId);
            // bind the data bound controls to the data source
        grid.DataBind();
    }
Posted
Updated 15-Feb-10 23:24pm
v2

jellybeannn wrote:
C#
return BuildAbsolute(String.Format("WidthAdmin.aspx?Width={0}", widthId));


jellybeannn wrote:
C#
Server.UrlDecode(Request.QueryString["WidthID"])


You're building the query with Width and trying to retrieve it with WidthID.

Nick
 
Share this answer
 
Thank you so much Nick it works now, you are a life saver :-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900