0

I have one asp:DropDownList in my page and how can i get this input's value on form submit.

i can get Request["name"];

but i can't get "parID" value

Request["parID"] does not work

parID.SelectedItem.Value does not work

How can I reach that ? or am i use wrong technique ? (form in webform creates problems? )

In the Categories.aspx

<asp:Content ContentPlaceHolderID="screen" ID="c1" runat="server">
    <div>
        <a href="Categories.aspx?w=add"><h4>Add new category</h4></a>
    </div>

    <% if(Request.QueryString["w"]=="add") { %>
    <form id="FormAddCategory" action="Categories.aspx?w=add" method="post">
        <table>
            <tr>
                <td>Category Name</td>
                <td>
                    <input type="text" name="name" />
                </td>
            </tr>
            <tr>
                <td>Parent Cat</td>
                <td>
                    <asp:DropDownList ID="parID" runat="server"></asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>

                </td>
                <td>
                    <input type="submit" name="submit" id="submit" value="Add" />
                </td>
            </tr>
        </table>
    </form>
    <% } else { %>

    ...
        GridView
    ...

    <% } %>
</asp:Content>

In the Categories.aspx.cs file:

protected void Page_Load(object sender, EventArgs e)
{
    if (ThisUser.isLoggedIn() && ThisUser.isAdmin)
    {
        if (Request.QueryString["w"] == "add" && Request.HttpMethod== "GET")
        {

            if (!IsPostBack)
            {
                ustID.Items.Clear();
                ustID.Items.Add(new ListItem("-", "0"));// for base category
                foreach (Category item in DB.Categories)
                {

                    ustID.Items.Add(new ListItem(item.name, item.ID.ToString()));
                }
            }


        }
        else if (Request.QueryString["w"] == "add" && Request.HttpMethod == "POST")
        {

            Category cat = new Category();

            cat.name = Request["name"];
            cat.parID = Convert.ToInt32(Request["parID"]);

            DB.Add(cat);

            Response.Redirect("Categories.aspx");



        }




    } else Response.Redirect("../Login.aspx?url=Admin/Categories.aspx");
}
Abdullah
  • 597
  • 7
  • 23
  • Your master page probably has a `form` already declared; which means you are probably [nesting `form`s which wont work](http://stackoverflow.com/questions/379610/can-you-nest-html-forms). – mshsayem May 22 '14 at 01:51
  • i know that but i can get `Request["name"];` value, the website seems to be working. If this is the problem how can i submit the form on webform the other page/QueryString – Abdullah May 22 '14 at 08:28

0 Answers0