rangerstud620 Posted July 12, 2005 Posted July 12, 2005 I'm sure this is simple to do but I'm stumped. I created an image gallery using a datalist. For each image, there are 2 radiobuttons (Approve, Disapprove). The radiobutton that needs to be checked is determined by the value of a field in a database. For example, if the DB field = "Y", the Approve radiobutton should be checked. If the DB field = "N", the Disapprove radiobutton should be checked. How do I get the correct radiobutton selected? Thanks Quote
kahlua001 Posted July 13, 2005 Posted July 13, 2005 In your itemdatabound event, something like If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim rbList As RadiobuttonList = e.Item.FindControl("rbList") If e.Item.DataItem("Approve") = "Y" Then rbList.Items.FindByValue("Approve").Selected = True Else rbList.Items.FindByValue("Disapprove").Selected = True End If End If make sure your radiobutonlist does not have anything selected or else you'll get an error, or unselect anything before you attempt to set an item. Quote
rangerstud620 Posted July 13, 2005 Author Posted July 13, 2005 Thanks kahlua001, that worked perfectly!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.