开发者

ASP dropdown list selected value

I have a page with "date" field as drop down list and submit button. When I click on submit the selected value is displayed in grid view in other page.

Now in the grid view I have a field like "edit", when I click on that it is navigated to first page with that date value. The problem is that this time "date which is passed from grid view " is not shown selected value in drop down list.

<asp:TemplateField HeaderText="DOB" SortExpression="dob">
            <ItemTemplate>
                   <asp:Label ID="lbldob" runat="server" Text='<%# Bind("dob") %>'>
                   </asp:Label>
            </ItemTemplate>
</asp:Templ开发者_高级运维ateField>

<asp:TemplateField HeaderText="Edit">
            <ItemTemplate>
                     <asp:LinkButton ID="hypeno" CommandName="cmdBind" runat="server" Text='<%# Eval("id") %>' CommandArgument='<%# Bind("id") %>'>
                     </asp:LinkButton>
           </ItemTemplate>
</asp:TemplateField>

Code:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "cmdBind")
        {
            string id = e.CommandArgument.ToString();
            LinkButton lb = (LinkButton)e.CommandSource;

            Response.Redirect("/practice/registation.aspx?id=" + id +"&type=edit");
        }

    }

      string type = Request.QueryString["type"].ToString();
       if (type == "edit")
       {                 connection con = new connection();
                     DataSet ds;
                     ds = con.select("select dob from registration where id='"+Request.QueryString["id"].ToString()+"'");

      drddate.SelectedItem.Text= ds.Tables[0].Rows[0][0].ToString();
        }


Post your code, but sounds to me like you have to set the selected value in your dropdown in the grids onrowdatabound event - but I'm not entirely sure based on the vagueness of your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜