ddl会先填充gridview,然后在gridview中使用#rows填充response.write,但要一按 [英] ddl populates gridview then response.write with #rows in gridview, but late one click
问题描述
从ddl中选择一个价格,以在gridview中填充价格低于或等于选定价格的商品.如果开始时且在gridview中只有一项,则response.write为null.否则,response.write应该显示项目数量和所选项目
价格.
问题是,当选择了价格,回复于职位的正确选择价格从DDL,但在GridView对应于屏幕前看到的量行的数量.如果来自gridview的数据被编辑或排序,它将
有效地显示正确的行数(ddl尚未更改,因此它显示的是上一屏幕的行数,该行数等于当前屏幕的行数.)
这是default.aspx.cs的代码:
公共局部类_Default:System.Web.UI.Page
{
字符串numberOfItems;
字符串selectedPrice;
受保护的void Page_Load(对象发送者,EventArgs e)
{
numberOfItems = Convert.ToString(GridView1.Rows.Count);
selectedPrice = ddlPrice.SelectedValue.ToString();
如果(!IsPostBack)
{
Response.Write(< br/>");
}
其他
{
如果(Convert.ToInt32(numberOfItems)< = 1)
{
Response.Write(< br/>");
}
如果(Convert.ToInt32(numberOfItems)> 1)
{
Response.Write("有" numberOfItems +
"价格为$的产品+选定的价格+或更少.");
}
}
}
受保护的void ddlPrice_SelectedIndexChanged(对象发送者,EventArgs e)
{
}
}
谢谢
Select a price from a ddl to populate a gridview with the items that cost the selected price or less. response.write is null at start and if there is only one item in the gridview. Else, response.write should display the amount of items and the selected
price.
The issue is that when a price is selected, response.write posts the correct selected price from the ddl, but the amount of rows from the gridview corresponds to the amount seen in the prior screen. If the data from the gridview is edited or sorted, it will
effectively show the correct amount of rows (the ddl has not been altered, so it shows the amount from the previous screen, which equals the amount of the current screen.)
here is the code for default.aspx.cs:
public partial class _Default : System.Web.UI.Page
{
string numberOfItems;
string selectedPrice;
protected void Page_Load(object sender, EventArgs e)
{
numberOfItems = Convert.ToString(GridView1.Rows.Count);
selectedPrice = ddlPrice.SelectedValue.ToString();
if (!IsPostBack)
{
Response.Write("<br />");
}
else
{
if (Convert.ToInt32(numberOfItems) <= 1)
{
Response.Write("<br />");
}
if (Convert.ToInt32(numberOfItems) > 1)
{
Response.Write("There are " + numberOfItems +
" products that cost $" + selectedPrice + " or less.");
}
}
}
protected void ddlPrice_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Thank you
推荐答案
感谢您的信息!我建议将您的问题发布到MS论坛之一
首页 ›ASP.NET论坛 ›Web表单数据控件 Home › ASP.NET Forums › General ASP.NET › Web Forms Data Controls
这篇关于ddl会先填充gridview,然后在gridview中使用#rows填充response.write,但要一按的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!