Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to hide a button in datagrid unless specific text is in another cell.
Plz help..............
Posted
Comments
n.podbielski 3-Oct-12 3:45am    
Wow. Single sentence question.
If you want to get answer you must ask more explain-what-you-trying-to-do-and-what-you-problem-is questions.

Did you even care to read 'How to ask question' thread?
n.podbielski 3-Oct-12 5:31am    
Thats great.
n.podbielski 3-Oct-12 6:44am    
Great that at least you read that. It's a start. Now read those on the right when you ask new question. And edit your question above.
n.podbielski 3-Oct-12 7:55am    
You are ridiculous. I don't know people like you. I don't care what you think about yourself as part of some group of people. You don't want to waste your time about asking more descriptive questions then don't expect other people to waste their time answering.

There are NOT mine rules if you using some site, be humble and abide this site rules.
ManjIndian 3-Oct-12 8:09am    
you need not to waste ur time yar...

in gridview assign event handler for RowDataBound event as :
OnRowDataBound="gvFunds_RowDataBound"

The event handler will be similar to the following one :

C#
protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           DataRowView dv = ((System.Data.DataRowView)(e.Row.DataItem));

           Button btnEdit = (Button)e.Row.FindControl("btnTohide");

           if(dv["MyText"] != "ExpectedText")
           {
               btnEdit.Visible =false;
           }
        }
    }
 
Share this answer
 
v2
Comments
ManjIndian 3-Oct-12 7:04am    
thanks....
DataGridViewTextBoxCell txtcell = new DataGridViewTextBoxCell();

                       dr.Cells[7] = txtcell;

simply added this code block to the if block which satisfying my condition.
 
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