Get buttons visible falsehttp://forums.asp.net/t/1800608.aspx/1?Get+buttons+visible+falseSun, 06 May 2012 18:48:51 -040018006084967593http://forums.asp.net/p/1800608/4967593.aspx/1?Get+buttons+visible+falseGet buttons visible false <p>Hi,</p> <p>I have a Gridview that containes some users values. I want to set 2 butons to visible=false if the logon user is &quot;admin&quot;. For one user it's working fine, and for another not. I have no idea why. This is my code:</p> <p></p> <pre class="prettyprint">Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If (e.Row.RowState = DataControlRowState.Edit) OrElse (e.Row.RowState = (DataControlRowState.Alternate Or DataControlRowState.Edit)) Then Else Dim UserName As String = User.Identity.Name Dim usern As String = DirectCast(e.Row.FindControl(&quot;label3&quot;), Label).Text Dim edytuj As Button = DirectCast(e.Row.FindControl(&quot;button1&quot;), Button) Dim rola As String = DirectCast(e.Row.FindControl(&quot;label1&quot;), Label).Text Dim usu As Button = DirectCast(e.Row.FindControl(&quot;button3&quot;), Button) If UserName.Equals(usern) And rola.Equals(&quot;admin&quot;) Then edytuj.Visible = False usu.Visible = False End If End If End If End Sub</pre> <p><br> <br> </p> <p></p> 2012-05-06T11:11:30-04:004967597http://forums.asp.net/p/1800608/4967597.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <p>Hey</p> <p>what do u mean by &quot;&nbsp;<span>For one user it's working fine, and for another not. &quot;</span></p> 2012-05-06T11:14:14-04:004967602http://forums.asp.net/p/1800608/4967602.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <table> <tbody> <tr> <td>35</td> <td>1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td>Kondej</td> <td>452ea874-3c9e-4f5d-bb2d-9d25685c1f4a</td> <td>Kondi75</td> <td>admin</td> </tr> <tr> <td>38</td> <td>1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <td>Kondej</td> <td>264a4e7b-f38c-477b-8a3d-cb9b63c9f033</td> <td>spontan23</td> <td>admin</td> </tr> <tr> <td>NULL</td> <td>NULL</td> <td>NULL</td> <td>NULL</td> <td>NULL</td> <td> <p>NULL</p> </td> </tr> </tbody> </table> 2012-05-06T11:26:56-04:004967604http://forums.asp.net/p/1800608/4967604.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <p>This is data from my database. For user &quot;spontan23&quot; those buttons are not showing. But when I log for user &quot;Kondi75&quot; those buttons are shown for him and it shouldn't be.</p> 2012-05-06T11:28:34-04:004967638http://forums.asp.net/p/1800608/4967638.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <p>try to make your if statment as following</p> <pre class="prettyprint">If rola.toSring() = (&quot;admin&quot;) Then edytuj.Visible = False usu.Visible = False End If</pre> <pre class="prettyprint"><span class="typ">since if you don't the admin see these button just check this condition ,, why are you checking the name?</span></pre> 2012-05-06T12:33:12-04:004967680http://forums.asp.net/p/1800608/4967680.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <p>It didn't work. I check it on other users and only this one works fine. I mean &quot;spontan23&quot;. Maybe it's because of some cookies?</p> 2012-05-06T13:54:31-04:004967682http://forums.asp.net/p/1800608/4967682.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <p>you only need to check if he is admin right</p> <p>now your labels are getting data from database.</p> <p>and in both users role should be admin, try to debug and make sure that rola.toString is &quot;admin&quot;</p> <p>so check&nbsp;</p> <p></p> <pre class="prettyprint">if rola.Tostring() = &quot;admin&quot; then edytuj.Visible = False usu.Visible = False End If</pre> 2012-05-06T14:01:33-04:004967846http://forums.asp.net/p/1800608/4967846.aspx/1?Re+Get+buttons+visible+falseRe: Get buttons visible false <p>I want to check if user that is logon is an admin. I want to set for that kind of user edit button visible false, so that won't be a situation where there is no admin. But he should be able to change rule for other users.</p> <p></p> 2012-05-06T18:48:51-04:00