tags:

views:

72

answers:

2
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 { 
     string[] Cardio = (string[])objDocter.getDocter_acc_prof();

     if (e.Row.RowType == 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

A: 

Hey,

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.

Brian
@Brain: will you please give me a short example ... so it will be more productive for me .............Thank you
ashish
A: 
     if (((Label)e.Row.FindControl("lblProblemName")).Text == "Heart problem") 
     { 
          DropDownList ddlAssignDoc  
              = (DropDownList)e.Row.FindControl("ddlAssignDoc"); 
          ddlAssignDoc.DataSource = Cardio; 
          ddlAssignDoc.DataBind(); 

      } 
mangokun
@mangokum: thanks a lot it is working fine....
ashish
@mangokum: it is all about template column but how to compare bound field ???
ashish
first convert the bound column to a template column. then put a label inside this template column, so you can use FindControl.
mangokun