In DataGrid, we may need to implement this function-column radio, itself DataGrid provides the select command to implement this function. Another example can also utilize Radiobutton in the HTML control to achieve such functions, of course, this is also our habit.
Ok, now it is now realized. First join the DataGrid control on the page.
The first column is set to the template column, add the label to the item template and then bind DataGrid.
The specific format is as follows:
Itemtemplate>
Asp: templateColumn>
Ask: DataGrid>
Add a Label on the page (used to display the only item in DataGrid) and a Button (view the option), as follows:
In DataGrid's itemDatabase
If E.Item.itemType = ListItemType.AlternatingItem or E.Item.ItemType = ListItemType.Item THEN DIM LBL AS Label LBL = E.Item.FindControl ("Label2")
'Join Radio LBL .Text = " endiff
In Button's Click event
Label3.text = Request.form ("Myradiogroup")
DIM I as DataGridItem for Each I IITAGRID1.Items if IIITEMTYPE = ListItemType.alternatingItem or iitemtype = ListiteMtype.Item THEN DIM R AS LABEL R = I.FindControl ("label2")
If R.TEXT.INDEXOF (Label3.Text)> 0 Then R.Text = "" else r.Text = "
Ok, this can achieve a radio feature that utilizes the RADIO to implement DataGrid.
Figure:
When we choose one, click "View Select Content", as shown in the figure:
In vs.net2003, IIS5.0 test passes.