开发者

how to compare two column value in GridView?

开发者 https://www.devze.com 2023-01-16 04:27 出处:网络
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { string[] Cardio = (string[])objDocter.getDocter_acc_prof();
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 { 
     string[] Cardio = (string[])objDocter.getDocter_acc_prof();

     if (e.Row.RowTyp开发者_C百科e == DataControlRowType.DataRow)
     {
         if (e.Row.Cells[2].Text == "Heart problem")
         {
              DropDownList ddlAssignDoc 
                  = (DropDownList)e.Row.FindControl("ddlAssignDoc");
              ddlAssignDoc.DataSource = Cardio;
              ddlAssignDoc.DataBind();

          }

     }
 }

i want to compare two template column in grid view, but it is not working ..............please give the right way to compare two columns of GridView. Thank You


     if (((Label)e.Row.FindControl("lblProblemName")).Text == "Heart problem") 
     { 
          DropDownList ddlAssignDoc  
              = (DropDownList)e.Row.FindControl("ddlAssignDoc"); 
          ddlAssignDoc.DataSource = Cardio; 
          ddlAssignDoc.DataBind(); 

      } 


Template columns render their own content. You would have to get each control and compare the two controls within the template, by using FindControl as you do and comparing the underlying value. Cell.Text is only useful for bound controls.

0

精彩评论

暂无评论...
验证码 换一张
取 消