gridview下拉列表在单击编辑按钮时未显示当前状态 [英] gridview dropdown not showing the current state when edit button is clicked
本文介绍了gridview下拉列表在单击编辑按钮时未显示当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早上好,
我在gridview中有一个下拉菜单。当我在gridview中选择编辑时,它没有显示当前的下拉状态。
我有3件物品在下拉列表中选择,消耗品,非消耗品。
假设消耗品已被选中,我点击编辑,然后它没有显示
耗材但显示选择。
请帮助我。
谢谢。
我在这里发帖子代码:
good morning,
i have a dropdown in gridview. when i select the edit in gridview, it is not showing the current state of dropdown.
I have 3 items Select,Consumable,non-Consumable in the dropdown.
Assume that consumable is already selected and i clicked on edit,then it is not showing
consumable but it is showing Select.
please help me.
thank you.
Here I am posting my code:
protected void grdItems_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
lblMsg.Text = string.Empty;
ItemManagementObject item = new ItemManagementObject();
ItemManagementDetails Itemdetails = new ItemManagementDetails();
Status status = new Status();
InventoryClient objService = new InventoryClient();
try
{
string Id = grdItems.DataKeys[e.RowIndex].Value.ToString();
GridViewRow row = grdItems.Rows[e.RowIndex];
//Label id = (Label)row.FindControl("uplbluserid");
TextBox itemname = (TextBox)row.FindControl("txtItemName");
DropDownList itemtype = (DropDownList)row.FindControl("ddlItemType");
TextBox location = (TextBox)row.FindControl("txtLocation");
TextBox Quantity = (TextBox)row.FindControl("txtQty");
TextBox UnitCost = (TextBox)row.FindControl("txtUnitCost");
item.Id = Convert.ToInt32(Id);
item.StoreId = Convert.ToInt32(ddlStoreId.SelectedValue);
item.ItemName = itemname.Text;
item.ItemType = Convert.ToInt32(itemtype.SelectedItem.Value);
item.Location = location.Text;
item.Quantity = Convert.ToDecimal(Quantity.Text);
item.Cost = Convert.ToDecimal(UnitCost.Text);
status = objService.FillValuesItem(item);
if (status.CallStatus == true)
{
if (status.ProcedureStatus == true)
{
lblMsg.Text = "Saved Successfully";
}
else
{
lblMsg.Text = "ItemName are already exists";
}
}
grdItems.EditIndex = -1;
BindGrid();
}
}
[/ EDIT]
[/EDIT]
推荐答案
请按照以下步骤操作:
转到
- >您的girdview的RowDataBoud事件。
- >检查项目是否处于编辑模式。
- >找到下拉列表控件。
- >设置控件的选定值。
OR
Follow the steps below:
Go to
--> RowDataBoud event of your girdview.
--> Check if item is in edit mode.
--> Find the dropdownlist control.
--> Set the selected value of the control.
OR
<edititemtemplate>
<asp:dropdownlist id="ddlEditMode" runat="server" selectedvalue="<%#Eval("YourDataSourceColumnName")%>" xmlns:asp="#unknown">
</asp:dropdownlist></edititemtemplate>
--Amit
--Amit
>
这篇关于gridview下拉列表在单击编辑按钮时未显示当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文