views:

1030

answers:

4

In the GridView we are using an edit button. Once the edit button is clicked Controls in the edit template will display in the same row with update button. That row has two dropdownlist controls.

Process flow:

controls:d1 and d2

d1 is using sqldatasource for item display : working fine.

d2 is using codebehind code to load the item based on the selected value in the d1 : Not working

How to find the control in the edit template to display item value for d2?

A: 

When you switch to the edit mode, you need to rebind the grid for this to take effect.

So, you can use the 'RowDataBound' event.

  void MyGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
  {
    if(e.Row.RowType == DataControlRowType.DataRow
            && e.Row.RowIndex == MyGridView.EditIndex)
    {
      DropDownList d1 = e.Row.FindControl("d1") as DropDownList;
      if(d1 == null) return;
      //Now you have the drop down. Use it as you wish.
    }
  }
Mohamed Meligy
+1  A: 

Hi,

I got the answer.

protected void GridView1_PreRender(object sender, EventArgs e)
 {
  if (this.GridView1.EditIndex != -1)
   {
     Button b = GridView1.Rows[GridView1.EditIndex].FindControl("Button1") as Button;
     if (b != null)
      {
      //do something
      }
   }
 }
Geetha
A: 

HOW CAN I APPLY THIS TO FIND FILEUPLOAD

TARIK
A: 

i want to put this control that i write this message in in .net is this rich text box and is this control has databind

Saeed