J
Jared
Hello all,
I'm looking for the best way to wrap my cell contents in a html label
tag. The results I'm looking for will allow the user to select the checkbox
when any cell in the tablerow is clicked. Keep in mind that these rows are
generated by a datagrid control. I would like to use strait forward
solutions without doing a lot of unnecessary server processing.
' Before
<tr class="Row">
<td><input id="MyGrid__ctl4_chkBox" type="checkbox"
name="MyGrid:_ctl4:chkBox" /></td>
<td>Some simple text</td>
<td>Some more text</td>
</tr>
' After
<tr class="Row">
<td><input id="MyGrid__ctl4_chkBox" type="checkbox"
name="MyGrid:_ctl4:chkBox" /></td>
<td><label for="MyGrid__ctl4_chkBox">Some simple text</label></td>
<td><label for="MyGrid__ctl4_chkBox">Some more text</label></td>
</tr>
I am appending the label markup in the ItemCreated handler, is there a
better way?
' My Current Working Code - Is there a better way?
Dim id As String = e.Item.FindControl("chkBox").ClientID
For i As Integer = 1 To e.Item.Cells.Count
e.Item.Cells(i).Text = _
"<label for=""" & id & """>" _
& e.Item.Cells(i).Text & "</label>"
Next
TIA,
Jared
I'm looking for the best way to wrap my cell contents in a html label
tag. The results I'm looking for will allow the user to select the checkbox
when any cell in the tablerow is clicked. Keep in mind that these rows are
generated by a datagrid control. I would like to use strait forward
solutions without doing a lot of unnecessary server processing.
' Before
<tr class="Row">
<td><input id="MyGrid__ctl4_chkBox" type="checkbox"
name="MyGrid:_ctl4:chkBox" /></td>
<td>Some simple text</td>
<td>Some more text</td>
</tr>
' After
<tr class="Row">
<td><input id="MyGrid__ctl4_chkBox" type="checkbox"
name="MyGrid:_ctl4:chkBox" /></td>
<td><label for="MyGrid__ctl4_chkBox">Some simple text</label></td>
<td><label for="MyGrid__ctl4_chkBox">Some more text</label></td>
</tr>
I am appending the label markup in the ItemCreated handler, is there a
better way?
' My Current Working Code - Is there a better way?
Dim id As String = e.Item.FindControl("chkBox").ClientID
For i As Integer = 1 To e.Item.Cells.Count
e.Item.Cells(i).Text = _
"<label for=""" & id & """>" _
& e.Item.Cells(i).Text & "</label>"
Next
TIA,
Jared