Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Paul Mason #1
Adding a select column...
Hi folks,
I am aiming to create a "select" column that is unbound on datagrid whose
other columns are all data bound. The idea is to let the user select items
to be printed etc.
The problem I have arises when I want to find out which rows are selected.
The following code is a tester that puts values into a string to be
displayed, but it's representative.
Dim chk As CheckBox
Dim itm As DataGridItem
Dim str As String
For Each itm In Me.dgVialList.Items
chk = CType(itm.Cells(0).Controls(0), CheckBox)
If chk.Checked Then
str += itm.Cells(1).Text & ", "
End If
Next
The problem occurs at chk = CType(itm.Cells(0).Controls(0), CheckBox) where
it says that it cannot cast the item as a checkbox. This collection is base
0?? I have only one template control (ItemTemplate).
Any ideas?
Cheers...P
Paul Mason Guest
-
Select after insert to the unique column
On Wed, Dec 08, 2004 at 14:50:04 +0100, Julian Legeny <legeny@softhome.net> wrote: Depending on what you really want to do, you could do each... -
Select a COLUMN in a datagrid?
Hi, Can anyone suggest how to select or hilight a column in a Windows Forms datagrid, as visual feedback for an edit/copy command? I've tried... -
Getting column name in Select statement
How can I use the column_name provided from information_schema.columns in a Select statement that is used for extracting certain columns from a... -
Button Select Column
I put a select button in a datagrid, select a row works fine. Now hold down the shift key and select a second row, get jscript error. Is there... -
Select MAX based on partial column value?
I need to get the max # from the following row values based on a portion of the data: abcXXX01 abcXXX02 defXXX03 abcXXX04 abcYYY01 defYYY02... -
Paul Mason #2
Re: Adding a select column...
Many apologies folks...I needed to refer to itm.Cells(0).Controls(1). I'm
not sure why this should be so, but I've got it working now.
Cheers...P
"Paul Mason" <p.mason.2@bham.ac.uk> wrote in message
news:%23wz$ocjrFHA.2996@tk2msftngp13.phx.gbl...>
> Hi folks,
>
> I am aiming to create a "select" column that is unbound on datagrid whose
> other columns are all data bound. The idea is to let the user select
> items to be printed etc.
>
> The problem I have arises when I want to find out which rows are selected.
> The following code is a tester that puts values into a string to be
> displayed, but it's representative.
>
> Dim chk As CheckBox
>
> Dim itm As DataGridItem
>
> Dim str As String
>
> For Each itm In Me.dgVialList.Items
>
> chk = CType(itm.Cells(0).Controls(0), CheckBox)
>
> If chk.Checked Then
>
> str += itm.Cells(1).Text & ", "
>
> End If
>
> Next
>
> The problem occurs at chk = CType(itm.Cells(0).Controls(0), CheckBox)
> where it says that it cannot cast the item as a checkbox. This collection
> is base 0?? I have only one template control (ItemTemplate).
>
> Any ideas?
>
> Cheers...P
>
>
>
>
>
>
>
Paul Mason Guest
-
Elton Wang #3
Re: Adding a select column...
Hi Paul,
Actually, the better way is:
chk = CType(itm.FindControl(checkbox_ID), CheckBox)
So you don't need to worry about it's in Controls(0) or Controls(1).
HTH
"Paul Mason" <p.mason.2@bham.ac.uk> wrote in message
news:efgoYpjrFHA.1256@TK2MSFTNGP09.phx.gbl...whose>
> Many apologies folks...I needed to refer to itm.Cells(0).Controls(1). I'm
> not sure why this should be so, but I've got it working now.
>
> Cheers...P
>
>
> "Paul Mason" <p.mason.2@bham.ac.uk> wrote in message
> news:%23wz$ocjrFHA.2996@tk2msftngp13.phx.gbl...> >
> > Hi folks,
> >
> > I am aiming to create a "select" column that is unbound on datagridselected.> > other columns are all data bound. The idea is to let the user select
> > items to be printed etc.
> >
> > The problem I have arises when I want to find out which rows arecollection> > The following code is a tester that puts values into a string to be
> > displayed, but it's representative.
> >
> > Dim chk As CheckBox
> >
> > Dim itm As DataGridItem
> >
> > Dim str As String
> >
> > For Each itm In Me.dgVialList.Items
> >
> > chk = CType(itm.Cells(0).Controls(0), CheckBox)
> >
> > If chk.Checked Then
> >
> > str += itm.Cells(1).Text & ", "
> >
> > End If
> >
> > Next
> >
> > The problem occurs at chk = CType(itm.Cells(0).Controls(0), CheckBox)
> > where it says that it cannot cast the item as a checkbox. This>> > is base 0?? I have only one template control (ItemTemplate).
> >
> > Any ideas?
> >
> > Cheers...P
> >
> >
> >
> >
> >
> >
> >
>
Elton Wang Guest



Reply With Quote

