开发者

how to compare two column value in GridView?

 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜