Last post May 14, 2016 03:22 AM by Zhi Lv - MSFT
May 13, 2016 11:59 AMfirstname.lastname@example.org|LINK
I have 2 radiobuttons, gridview
on clicking yes radio button gridview displays....grid view has add,edit,delete.
if user cliks no...no gridview displayed
now I want an if startment which says if GridView1 has data..then radiobuttonno.visible=false
how do I write this in pageload?
May 13, 2016 12:08 PM|mgebhard|LINK
Well, if the gridview's data source has records then set radio button visibility.
It would help if you posted the relevant source code rather than making us guess.
May 13, 2016 11:03 PMemail@example.com|LINK
Protected Sub SqlDataSourceab_Deleting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSourceab.Deleting
Radiobutton2.Visible = True
On this page I have Gridview1
On delete command I want to check if there are any rows in the gridview, if yes then radiobutton2.visible=false
else if no rows in the gridview to delete then radiobutton1.visible=true
May 14, 2016 03:22 AM|Zhi Lv - MSFT|LINK
From my point of view, I suggest you can use GridView DataBound event. you can refer to the following code:
Protected Sub GridView1_DataBound(sender As Object, e As EventArgs)
If GridView1.Rows.Count = 0 Then
radiobutton.Visible = False
radiobutton.Visible = True