Template Column and Checkbox's 
Author Message
 Template Column and Checkbox's

Hi.

I am creating a VB.NET ASP web application. On my web form, I've created a
template column in my databound grid. I added a checkbox to the template so
a user can select multiple items. When they click the "Refund" button, I
need to determine which items in the list have been selected.

I cannot figure out how to determine which checkboxes have been checked. Is
there a collection or something that I am missing? I am using VB.NET and it
seems to generate the ID's and NAME's automatically for each row's checkbox.
I can't imagine I have to hard code the name in the refund button's click
event.

Any thoughts?

Thanks-
Dave



Mon, 26 Jul 2004 04:19:55 GMT  
 Template Column and Checkbox's
You can look it up in the .net msdn under the caption: "Allowing Users to
Delete Items in a DataList Web Server Control" The code specified there is:

  1..
    1.. Private Sub DeleteAll_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Delete.Click
   Dim isDeleted As Boolean
   Dim anItem As DataListItem

   ' Check each box and see if the item should be deleted.
   For Each anItem In DataList1.Items
      isDeleted = CType(anItem.FindControl("Delete"), CheckBox).Checked
      If isDeleted Then
         ' Add code here to delete the item, using anItem.ItemIndex.
      End If
   Next
   DataList1.DataBind()
End Sub

You just need to change the DataListItem to DataGridItem


Quote:
> Hi.

> I am creating a VB.NET ASP web application. On my web form, I've created a
> template column in my databound grid. I added a checkbox to the template
so
> a user can select multiple items. When they click the "Refund" button, I
> need to determine which items in the list have been selected.

> I cannot figure out how to determine which checkboxes have been checked.
Is
> there a collection or something that I am missing? I am using VB.NET and
it
> seems to generate the ID's and NAME's automatically for each row's
checkbox.
> I can't imagine I have to hard code the name in the refund button's click
> event.

> Any thoughts?

> Thanks-
> Dave



Mon, 26 Jul 2004 17:22:18 GMT  
 Template Column and Checkbox's
O, and a further note ...

1. Make sure that you do not set the the checkbox control within the
datagrid's autopostback to true
2. Make sure that you do not databind the datagrid each time the page is
loaded, e.g.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

    If Not Page.IsPostBack Then

        Me.myDataGrid.DataBind()

    End If

End Sub


Quote:
> You can look it up in the .net msdn under the caption: "Allowing Users to
> Delete Items in a DataList Web Server Control" The code specified there
is:

>   1..
>     1.. Private Sub DeleteAll_Click(ByVal sender As Object, _
> ByVal e As System.EventArgs) Handles Delete.Click
>    Dim isDeleted As Boolean
>    Dim anItem As DataListItem

>    ' Check each box and see if the item should be deleted.
>    For Each anItem In DataList1.Items
>       isDeleted = CType(anItem.FindControl("Delete"), CheckBox).Checked
>       If isDeleted Then
>          ' Add code here to delete the item, using anItem.ItemIndex.
>       End If
>    Next
>    DataList1.DataBind()
> End Sub

> You just need to change the DataListItem to DataGridItem



> > Hi.

> > I am creating a VB.NET ASP web application. On my web form, I've created
a
> > template column in my databound grid. I added a checkbox to the template
> so
> > a user can select multiple items. When they click the "Refund" button, I
> > need to determine which items in the list have been selected.

> > I cannot figure out how to determine which checkboxes have been checked.
> Is
> > there a collection or something that I am missing? I am using VB.NET and
> it
> > seems to generate the ID's and NAME's automatically for each row's
> checkbox.
> > I can't imagine I have to hard code the name in the refund button's
click
> > event.

> > Any thoughts?

> > Thanks-
> > Dave



Mon, 26 Jul 2004 17:31:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dynamically Added Datagrid Template Column - Checkbox.Checked state in Column Header

2. Checkbox in multi-column listbox or grid column?

3. Multi-column listbox w/3 columns of checkboxes

4. Multi-column listbox w/3 columns of checkboxes

5. only allowing one checkbox to be checked on template

6. Checkbox on FAX Template

7. Calculate checkbox value on a template

8. Inserting a Checkbox into a Document Template

9. 'Repeating' template strategy

10. Dynamic DataGrid Template Columns using ascx

11. Datagrid web control problem: creating event handlers for contols in template columns

12. VB template columns

 

 
Powered by phpBB® Forum Software