0
我有一个页面,“日期”字段作为下拉列表并提交按钮。当我点击提交时,所选值将显示在其他页面的网格视图中。ASP下拉列表选定的值
现在在网格视图中,我有一个类似“编辑”的字段,当我点击它时,它被导航到具有该日期值的第一页。问题是,这次“从网格视图传递的日期”在下拉列表中未显示选定的值。
<asp:TemplateField HeaderText="DOB" SortExpression="dob">
<ItemTemplate>
<asp:Label ID="lbldob" runat="server" Text='<%# Bind("dob") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="hypeno" CommandName="cmdBind" runat="server" Text='<%# Eval("id") %>' CommandArgument='<%# Bind("id") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
代码:像你这样在电网的下拉onrowdatabound事件来设置所选值
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();
}
请发布您的代码 – 2011-05-13 12:37:15
如果您正在导航回第一页,您可能会将编辑日期作为查询字符串/会话传递。因此,您可能必须从后面的代码中选择它,并且如果编辑的日期是新的日期,则需要将其添加并重新绑定。 – Raghav 2011-05-13 12:39:43
我相信你有回发的问题,但要获得更多帮助,请提交代码。 – 2011-05-13 12:40:07