[VS03] Datagrid Checkbox

Joined
Feb 10, 2009
Messages
2
Reaction score
0
Hi all,

I'm New of ASP.Net. Currently, I faced a problem of datagrid of ASP.Net 1.1 checkbox problem.

I had created a templatecolumns for checkbox as show at below.

PHP:
<asp:TemplateColumn>
							<ItemStyle Width="25px"></ItemStyle>
							<ItemTemplate>
								<asp:CheckBox id="check" AutoPostBack="True" Runat="server"></asp:CheckBox>
							</ItemTemplate>
						</asp:TemplateColumn>

I would like to enable the user to check on datagrid checkbox.
After user checked on that, the selected rows would be change to red color
and another templatescolumn which contains a pushbutton will set the button to be visible.

Thus, I had tried to get the event handle of checkbox.

PHP:
Private Sub dgSchoolName_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgSchoolName.ItemCreated
        Dim chk As CheckBox
        Select Case e.Item.ItemType
            Case ListItemType.Item, ListItemType.AlternatingItem
                chk = CType(e.Item.FindControl("check"), CheckBox)
                AddHandler chk.CheckedChanged, AddressOf chk_CheckedChanged

        End Select
    End Sub


Public Sub chk_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)

        Dim chk As CheckBox = CType(sender, CheckBox)
        Dim objItem As DataGridItem = CType(chk.Parent.Parent, DataGridItem)
        Dim chkIndex As Double = Convert.ToInt32(objItem.ItemIndex)
       
        If Page.IsPostBack Then
            If chk.Checked = True Then
                '----> row color change to red and button visible = true
            Else
                '----> row color change to default and button visible = false
            End If

        End If
    End Sub

But It cannot worked. Can anyone try to rectify my faults ?

Somemore, It is possible that the pushbutton only display one button of that rows instead every rows?

Thanks for a million.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top