Click here to Skip to main content
15,893,994 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hi Expert,

In My website Nridubai.com website i am showing

all companies and their information to admin.

For this purpose I have use gridview control, And each gridview cell is clickable.

And i am using following code for this,

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              LinkButton _singleClickButton = (LinkButton)e.Row.Cells[0].Controls[0];
              string _jsSingle = ClientScript.GetPostBackClientHyperlink(_singleClickButton, "");
              // Add events to each editable cell
              for (int columnIndex = 0; columnIndex < e.Row.Cells.Count; columnIndex++)
              {
                  // Add the column index as the event argument parameter
                  string js = _jsSingle.Insert(_jsSingle.Length - 2, columnIndex.ToString());
                  // Add this javascript to the onclick Attribute of the cell
                  e.Row.Cells[columnIndex].Attributes["onclick"] = js;
                  // Add a cursor style to the cells
                  e.Row.Cells[columnIndex].Attributes["style"] += "cursor:pointer;cursor:hand;";
              }
          }
      }
  }


And I am fetching cell column index and row index on GridView1_RowCommand event

Upto this working fine for me.


Now i have to display each cell value in popup when i click.

And i now i am using MOdalpopup extender(mpe).In that i take 2 textbox one for company and second for color.

But when i click cell,it opens modalpopup correctly,but failed to display the value associated with textboxes.

During debuging values assigning properly to textbox.but when it opens popup ,textboxes showing blank value.and if suppose i type something in it and close and then open modalpop again ,they showing existing values.

And i think this problem occurs due to following method

C#
protected override void Render(HtmlTextWriter writer)
   {
       foreach (GridViewRow r in GridView1.Rows)
       {
           if (r.RowType == DataControlRowType.DataRow)
           {
               for (int columnIndex = 0; columnIndex < r.Cells.Count; columnIndex++)
               {
                   Page.ClientScript.RegisterForEventValidation(r.UniqueID + "$ctl00", columnIndex.ToString());
               }
           }
       }

       base.Render(writer);
   }



Please help me sort out the problem,And sorry for my poor english.

Thanks in advance.
Posted

1 solution

Sorry everyone,i forgot to include update panel.

Now above code is working fine for me.
 
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