Hello guys,
I am using GridView to display a list of forms submitted by a user and in one of the column I have a LinkButton which has got a conditional logic behind it to either display or hide it. The pseudo code for logic basically goes like this:
If User has received a comment
Show the link to the comment on the GridView.
Else
Hide Link
This is the SQL that checks whether the user has got a comment for each submitted form:
Sql = "SELECT * FROM TableStudent INNER JOIN TableComment ON TableStudent .sID= TableComment .sID WHERE TableStudent .sID=@sID"
The SQL is working fine but I am having problem with looping through each form row to check if they have comment or not. Currently, the code hides the first row (correctly) but does not seem to be hiding the link for the following rows that does not have comments. I think my syntax for looping throw each row is incorrect.
For Each row As GridViewRow In gv1.Rows
If ds.Tables(0).Rows.Count = 0 Then
TryCast(gv1.Rows(0).FindControl("lnkBtnComment").FindControl("lnkBtnComment"), LinkButton).Visible = False
Else
TryCast(gv1.Rows(0).FindControl("lnkBtnComment").FindControl("lnkBtnComment"), LinkButton).Visible = True
End If
Next

I revised the code as it seemed to be affecting only the first column and changed it to this:
For Each gvrow As GridViewRow In gv1.Rows
If ds.Tables(0).Rows.Count = 0 Then
TryCast(gvrow.FindControl("lnkDisplayComment"), LinkButton).Visible = False
Response.Write(ds.Tables(0).Rows.Count)
Else
TryCast(gvrow.FindControl("lnkDisplayComment"), LinkButton).Visible = True
Response.Write(ds.Tables(0).Rows.Count)
End If
Next
Now the output for this has been if the associated form has any comment, it shows all the links and if the associated form has no comment, the comment links are hidden.
And I have one applicant with two forms submitted; one of them has comment and the other does not. But my repsonse.write is returning 1 for both rows when I should clearly be 0 as it does not have any associated comment.
Thank you very much for your time.
P.S. For some reason the facebook login is not working and giving
Server Error in '/' Application.
And redirecting to this path (http://www.aspforums.net/PageNotFound.aspx?aspxerrorpath=/Home.aspx)