如何在gridview内的下拉菜单中添加项目以及如何绑定它 [英] how to add items to the dropdown inside gridview and how to bind it
问题描述
如何在gridview内的下拉菜单中添加值,以及如何在asp.net中为gridview内的下拉菜单编写selectedIndexchanged事件的代码
我的表格在gridview中具有三列,其中之一是数量(下拉列表)以及价格和金额,我想在gridview中计算金额.如果我选择的数量是2,那么它将计算数量*价格,我如何才能在gridview或其他任何选项中获取selectedIndexchanged属性以用于下拉菜单.请帮帮我.
问候,
P.Maruthi
how to add values to the dropdown inside gridview and how to write the code for selectedindexchanged event for dropdown inside gridview in asp.net
my form having three columns in gridview one is quantity (dropdown list) and price and amount i want to calculate amount inside gridview. if i selected quantity is 2 then it calculate quatity* price how can i get the selectedindexchanged property for dropdown inside gridview or any other options. please help me.
Regards,
P.Maruthi
推荐答案
这可能对您有帮助
http://forums.asp.net/t/1313185.aspx /1 [ ^ ]
This may help you
http://forums.asp.net/t/1313185.aspx/1[^]
//inside rowdatabound of gridview find the dropdown and bind it like below
DropDownList ddlQuantity = e.Row.FindControl("ddlQuantity");
// now you have a ddl
//{ write a method here to bind the ddl }
// write this into the selectedindex_change of ddlQuantity
Control ddlQuantity = (DropDownList)sender as Control;
GridViewRow gvRow = ddlQuantity.NamingContainer as GridViewRow;
//now you have the current row of the grid where the dropdown is
// lets the dropdown selected value is 2 then
Label price = (Label)gvReplyAdded.Rows[gvRow.RowIndex].FindControl("lblPrice");
Label Amount = (Label)gvReplyAdded.Rows[gvRow.RowIndex].FindControl("lblAmount");
Amount.Text = (Convert.ToInt32(price.Text) * Convert.ToInt32(((DropDownList)sender).SelectedValue)).ToString();
//here you can get the control of gridview of the same row
请参阅一些链接:
从GridView控件中提高DropDownList SelectedIndexChanged [ DropDownList SelectedIndexChanged [ ASP.Net中的Gridview DropDownList SelectedValue [ DropDownList SelectedIndexChanged [ DropDownList SelectedIndexChanged事件未在GridView中触发 [ ^ ]
Gridview下拉列表selectedindexchanged [
Please refer some links:
Raising DropDownList SelectedIndexChanged From GridView Control[^]
DropDownList SelectedIndexChanged in gridview[^]
Gridview DropDownList SelectedValue in ASP.Net[^]
Similar discussion:
DropDownList SelectedIndexChanged within Gridview[^]
DropDownList SelectedIndexChanged event not firing within GridView[^]
Gridview dropdownlist selectedindexchanged[^]
这篇关于如何在gridview内的下拉菜单中添加项目以及如何绑定它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!