Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table and i populate it dynamically using c#. In each row i have a link button with a specific ID. This ID is as follows "EDIT#" + data.rows[index]["ID"]. How can I find all these linkbuttons when i click a button and then just make it enabled=false

Here is the code i have which i thought would work. However, it doesnt even go into this code on debug

C#
int row = 0;
foreach (var button in callData.Rows[row].Controls.OfType<LinkButton>())
   {
      button.Enabled = false;
      row = row++;
   }      



Please point me in the direction.
Posted
Updated 20-Jun-15 1:48am
v2

The easiest way would be the place where you are creating the LinkButtons. At that place only, set linkButtonId.Enabled = false;.
 
Share this answer
 
Comments
Member 10395722 20-Jun-15 7:47am    
I have update the question
Which table you are using?
Member 10395722 20-Jun-15 8:08am    
I am using an HTML Table
See this answer - iterate through rows in an html table with c#. You need to do like this.
C#
foreach(var row in callData.Rows)
{
    foreach (var button in row.Controls.OfType<LinkButton>())
    {
       button.Enabled = false;
    }
}
 
Share this answer
 
I have finally solved this issue. With many more google searches and the code F-ES Stercore gave, I could get the rest of the code done.

For those who are interested, here is what i did
C#
  foreach (HtmlTableRow row in callData.Rows)
        {
            foreach (HtmlTableCell cell in row.Cells)
            {
                foreach (var linkbtn in cell.Controls.OfType<linkbutton>())
                {
                    if (linkbtn.Text == "Edit")
                    {
                        linkbtn.Visible = false;
                    }
                }  
            }                
        }
</linkbutton>
 
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