Click here to Skip to main content
16,013,648 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get Gridview Cell value Dropdown list wise Update,below SourceCode(.CS) not get gvrow.Cells[3].Text


Source code(.cs)
C#
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;
                }
          
        }

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
Posted
Updated 9-Nov-14 3:35am
v4
Comments
Kornfeld Eliyahu Peter 9-Nov-14 9:41am    
Do you have any errors? Or just the returned value is something else than you have expected?
Please describe it with more details!
Also remember that array indexes are zero based...
MJ2014 9-Nov-14 12:34pm    
Pls describe your question in detail.

1 solution

C#
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;
    }
}

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900