如何在c#中获取gridview下拉项模板值
问题描述:
如何获取Gridview Cell值下拉列表明智更新,在SourceCode(.CS)下面没有得到gvrow.Cells [3] .Text
源代码(.cs)
How to get Gridview Cell value Dropdown list wise Update,below SourceCode(.CS) not get gvrow.Cells[3].Text
Source code(.cs)
protected void ddlInformType_OnSelectedIndexChanged(object sender, EventArgs e)
{
double leave = 0;
GridViewRow gvrow = ((DropDownList)sender).Parent.Parent as GridViewRow;
DropDownList ddlInformType = (DropDownList)gvrow.FindControl("ddlInformType");
if (ddlInformType.SelectedValue == "Prior")
{
leave = Convert.ToDouble(gvrow.Cells[3].Text) - 1;
return;
}
if (ddlInformType.SelectedValue == "Late informed")
{
leave = Convert.ToDouble(ViewState["Leave"].ToString()) - 0.5;
return;
}
if (ddlInformType.SelectedValue == "Not Informed")
{
leave = Convert.ToDouble(gvrow.Cells[4].Text) + 1;
return;
}
}
此来源未获取gvrow.Cells [3] .Text值所以如何获取gridview单元格值
i想要在gridview中更新gvrow.Cells [3] .Text
谢谢
This Source Not get gvrow.Cells[3].Text values So how to get gridview cell value
i want Update gvrow.Cells[3].Text in gridview
Thanks
答
foreach(GridViewRow row in allRmaGv.Rows)
{
// Try to find the `dcDdl` in data rows only, because they do not exist in header or footer rows
if (row.RowType == DataControlRowType.DataRow)
{
DropDownList dcDropDown = (DropDownList)row.FindControl("dcDdl");
dcDropDown.SelectedValue = value;
}
}