Gridview中的下拉菜单 [英] Dropdown in Gridview
本文介绍了Gridview中的下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在gridview中添加一个下拉列表.在我的应用程序中,我想从用户输入的第一个下拉列表的值中填充第二个下拉列表的值. IE.在第一个下拉列表中,我想填写产品名称.当我选择产品名称时,我想在第二个下拉列表中填写与我从第一个下拉列表中选择的产品名称相关的价格.
我该怎么办?
如果您能用C#中的代码证明我,将不胜感激!
I want to add a drop-down in a gridview. In my application i want to fill values of second dropdown from the value of first dropdown which is entered by the user. ie. In first dropdown i want to fill the product name.When i select product name then i want to fill the second dropdown with price related to that product name which i selected from the first dropdown.
How can i do it?
if you can proved me with the code in C# it would be grateful!!
推荐答案
您的问题是一些令人困惑的措辞
据我了解
这可能会给您一些想法
http://forums.asp. net/t/1431726.aspx/1?populate +一个+下拉列表+基于+ on + action + of +另一个+下拉列表 [
Your question is some what confusing rephrase it
as far as i understood
This may give you some idea
http://forums.asp.net/t/1431726.aspx/1?populate+one+dropdownlist+based+upon+action+of+another+dropdownlist[^]
有关在gridview中添加下拉列表的信息,请参见:
http://highoncoding.com/Articles/169_DropDownList_Inside_GridView__Method_1_.aspx [
for adding a dropdown in gridview refer:
http://highoncoding.com/Articles/169_DropDownList_Inside_GridView__Method_1_.aspx[^]
and for having the the items in the secodd dropdown depending on selection of first dropdown u should use SelectedIndexChanged event of first dropdown, as:
protected void ddlProduct_SelectedIndexChanged(object sender, EventArgs e)
{
int product_id= Convert.ToInt32(ddlProduct.SelectedValue);
ds = belobj.GetDataSet("GetPrice", "PRODUCT_ID=" + product_id);//get the values for price from database
ddlPrice.DataSource = ds.Tables[0];
ddlPrice.DataBind();
}
您确实应该以面向对象的方式执行此操作.您应该有一个名为Product的类.然后,当用户打开开票表单时,应在产品组合框"中填充产品列表".当用户从组合中选择一个产品时,零售价格和所有内容都将自动包含在该类中,因此您可以使用零售价格填充文本框,并使用可用数量填充另一个文本框,然后用户只需选择一个带有数字上下控件的数量,然后单击添加按钮,该按钮将在DataGridView中包括选定的项目和数量.然后,您可以使用保存并打印"按钮将订单保存到数据库并打印收据/发票.
希望对您有帮助
You really should be doing this in an Object Oriented manner. You should have a class called Product. Then when your user opens the billing form, you should populate the Product ComboBox with a List of the Products. When the user selects a Product from the Combo, the retail price and everything is automatically included as part of the class, and so you could populate a Textbox with the retail price and maybe another with the available quantity, then the user can just select a quantity with a numeric up down control and click an addtobill button which then includes the selected item and quantity in the DataGridView. Then you couls have a saveandprint button which saves the order to the database and prints a receipt/invoice.
Hope this helps
这篇关于Gridview中的下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文