CodeSnip: How to Create a DataGrid in ASP.NET with Multiple Radio Buttons Per Row
page 3 of 5
by Nidal Arabi
Feedback
Average Rating: 
Views (Total / Last 10 Days): 23444/ 74

Testing

If you run your project now, you will receive Figure 3, but when you click process nothing happens (except posting back the page).

Figure 3

In order to process the rows after user selection of options, you have to post the following code segment for the BtnProcess click event.

Listing 3

Private Sub BtnProcess_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) _
Handles BtnProcess.Click
  Dim RequestString As String, Ind As DataGridItem, RequestValue As String, RowNumber As Long
  RowNumber = 1
  For Each Ind In DataGrid1.Items
    RequestString = "mycheckoption" & Ind.ItemIndex
    If Ind.ItemType = ListItemType.AlternatingItem Or Ind.ItemType = ListItemType.Item Then
      Dim r As Label
      r = Ind.FindControl("LblStatus")
      RequestString = "mycheckoption" & Ind.ItemIndex
      RequestValue = Request.Form(RequestString)
      TxtProcess.Text = TxtProcess.Text & "Row " & RowNumber & " has status " & RequestValue & vbCrLf
      RowNumber + = 1
    End If
  Next
End Sub

Now run your project and make your selections then click the process button. Something similar to Figure 4 should happen depending on your selection.

Figure 4


View Entire Article

User Comments

Title: CodeSnip: How to Create a DataGrid in ASP.NET with Multiple Radio Buttons Per Row   
Name: Naina
Date: 2009-02-20 3:07:29 PM
Comment:
This was very useful...but can you please tell me how to maintain the selection between page post backs

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2020 ASPAlliance.com  |  Page Processed at 2020-10-25 1:12:11 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search