RE: 'Overall' Editing DataGrids

Discussion in 'ASP .Net' started by Mike Moore [MSFT], Nov 11, 2003.

  1. Hi Sebi,

    I created a sample grid with checkboxes. I can check & uncheck the boxes
    and submit the form. It will list back to me (correctly) which boxes are
    checked or not. I think this sample may help you.

    Add a grid & a button. Set the grid to have one template column with a
    check box in it.

    Here's my HTML

    <form id="Form1" method="post" runat="server">
    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
    absolute; TOP: 57px" runat="server"
    AutoGenerateColumns="False">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
    <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 8px; POSITION:
    absolute; TOP: 8px" runat="server"
    Text="Button"></asp:Button>
    </form>



    Next, my code-behind is very simple. It's all in the page_load.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Force "flow" layout
    DataGrid1.Attributes.Remove("style")
    Button1.Attributes.Remove("style")

    If Not Page.IsPostBack Then
    Dim MyList As New ArrayList
    Dim i As Int32
    For i = 0 To 3
    MyList.Add(i)
    Next
    DataGrid1.DataSource = MyList
    DataGrid1.DataBind()
    Else
    Dim i As Int32
    For i = 0 To DataGrid1.Items.Count - 1
    Dim ck As CheckBox
    ck = DataGrid1.Items(i).Cells(0).FindControl("CheckBox1")
    Response.Write(ck.Checked & "<br>")
    'add code here to select or deselect all
    'update the database here
    Next
    End If
    End Sub


    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > Content-Class: urn:content-classes:message
    > From: "Sebi" <>
    > Sender: "Sebi" <>
    > Subject: 'Overall' Editing DataGrids
    > Date: Tue, 11 Nov 2003 08:38:05 -0800
    > Lines: 22
    > Message-ID: <125d01c3a872$2e457d70$>
    > MIME-Version: 1.0
    > Content-Type: text/plain;
    > charset="iso-8859-1"
    > Content-Transfer-Encoding: 7bit
    > X-Newsreader: Microsoft CDO for Windows 2000
    > Thread-Index: AcOoci5FF7BRb9OBSVa+nWc4+8DI0g==
    > X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    > Path: cpmsftngxa06.phx.gbl
    > Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190088
    > NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    > Hello All,
    >
    > I'm using DataGrids mainly to display Data.
    > Now it should be possible for some Flags to be edited.
    > For this reason I've added CheckBoxes to the DataGrid.
    >
    > I don't want to add edit & update button.
    > I want to do a Global update including a
    > SelectAll/DeselectAll.
    >
    > The Problem is, that the Values don't seem to be updated.
    > When I read the Checked Flag of the Checkbox, it still
    > contains the Initial Value.
    >
    > Is there some Command like UpdateData(false)?
    > Or is there a Property that I might have set wrong?
    > Any Other Ideas how I can read the WebPage Values?
    >
    > Thanks a lot for any help
    >
    > Sebi
    >
    >
     
    Mike Moore [MSFT], Nov 11, 2003
    #1
    1. Advertising

  2. Mike Moore [MSFT]

    Sebi Guest

    Mike,

    Thanks.

    This is exactly what I do!!
    I do it in C#, but exactly the same, and I can only see
    the Initial Values. I've also seen another sample which
    works, but mine doesn't!!?!

    Anybody got a hint??

    - P L E A S E ! -

    >-----Original Message-----
    >Hi Sebi,
    >
    >I created a sample grid with checkboxes. I can check &

    uncheck the boxes
    >and submit the form. It will list back to me (correctly)

    which boxes are
    >checked or not. I think this sample may help you.
    >
    >Add a grid & a button. Set the grid to have one template

    column with a
    >check box in it.
    >
    >Here's my HTML
    >
    ><form id="Form1" method="post" runat="server">
    > <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101;

    LEFT: 16px; POSITION:
    >absolute; TOP: 57px" runat="server"
    > AutoGenerateColumns="False">
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:CheckBox id="CheckBox1"

    runat="server"></asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </asp:DataGrid>
    > <asp:Button id="Button1" style="Z-INDEX: 102; LEFT:

    8px; POSITION:
    >absolute; TOP: 8px" runat="server"
    > Text="Button"></asp:Button>
    ></form>
    >
    >
    >
    >Next, my code-behind is very simple. It's all in the

    page_load.
    >
    >Private Sub Page_Load(ByVal sender As System.Object,

    ByVal e As
    >System.EventArgs) Handles MyBase.Load
    > 'Force "flow" layout
    > DataGrid1.Attributes.Remove("style")
    > Button1.Attributes.Remove("style")
    >
    > If Not Page.IsPostBack Then
    > Dim MyList As New ArrayList
    > Dim i As Int32
    > For i = 0 To 3
    > MyList.Add(i)
    > Next
    > DataGrid1.DataSource = MyList
    > DataGrid1.DataBind()
    > Else
    > Dim i As Int32
    > For i = 0 To DataGrid1.Items.Count - 1
    > Dim ck As CheckBox
    > ck = DataGrid1.Items(i).Cells(0).FindControl

    ("CheckBox1")
    > Response.Write(ck.Checked & "<br>")
    > 'add code here to select or deselect all
    > 'update the database here
    > Next
    > End If
    >End Sub
    >
    >
    >Thank you, Mike
    >Microsoft, ASP.NET Support Professional
    >
    >Microsoft highly recommends to all of our customers

    that they visit the
    >http://www.microsoft.com/protect site and perform the

    three straightforward
    >steps listed to improve your computer's security.
    >
    >This posting is provided "AS IS", with no warranties,

    and confers no rights.
    >
    >
    >--------------------
    >> Content-Class: urn:content-classes:message
    >> From: "Sebi" <>
    >> Sender: "Sebi" <>
    >> Subject: 'Overall' Editing DataGrids
    >> Date: Tue, 11 Nov 2003 08:38:05 -0800
    >> Lines: 22
    >> Message-ID: <125d01c3a872$2e457d70$>
    >> MIME-Version: 1.0
    >> Content-Type: text/plain;
    >> charset="iso-8859-1"
    >> Content-Transfer-Encoding: 7bit
    >> X-Newsreader: Microsoft CDO for Windows 2000
    >> Thread-Index: AcOoci5FF7BRb9OBSVa+nWc4+8DI0g==
    >> X-MimeOLE: Produced By Microsoft MimeOLE

    V5.50.4910.0300
    >> Newsgroups: microsoft.public.dotnet.framework.aspnet
    >> Path: cpmsftngxa06.phx.gbl
    >> Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet:190088
    >> NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    >> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >>
    >> Hello All,
    >>
    >> I'm using DataGrids mainly to display Data.
    >> Now it should be possible for some Flags to be edited.
    >> For this reason I've added CheckBoxes to the DataGrid.
    >>
    >> I don't want to add edit & update button.
    >> I want to do a Global update including a
    >> SelectAll/DeselectAll.
    >>
    >> The Problem is, that the Values don't seem to be

    updated.
    >> When I read the Checked Flag of the Checkbox, it still
    >> contains the Initial Value.
    >>
    >> Is there some Command like UpdateData(false)?
    >> Or is there a Property that I might have set wrong?
    >> Any Other Ideas how I can read the WebPage Values?
    >>
    >> Thanks a lot for any help
    >>
    >> Sebi
    >>
    >>

    >
    >.
    >
     
    Sebi, Nov 12, 2003
    #2
    1. Advertising

  3. Hi Sebi,

    1) Does my sample work on your machine?

    2) Notice that my sample is very short and simple. Can you post a short
    and simple sample of your page?

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > Content-Class: urn:content-classes:message
    > From: "Sebi" <>
    > Sender: "Sebi" <>
    > References: <125d01c3a872$2e457d70$>

    <dqhbh$>
    > Subject: RE: 'Overall' Editing DataGrids
    > Date: Wed, 12 Nov 2003 01:05:50 -0800
    > Lines: 145
    > Message-ID: <026701c3a8fc$2b340400$>
    > MIME-Version: 1.0
    > Content-Type: text/plain;
    > charset="iso-8859-1"
    > Content-Transfer-Encoding: 7bit
    > X-Newsreader: Microsoft CDO for Windows 2000
    > X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    > Thread-Index: AcOo/CsxeZM/nrzDSIyHtD96cImBSw==
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    > Path: cpmsftngxa06.phx.gbl
    > Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190288
    > NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    > Mike,
    >
    > Thanks.
    >
    > This is exactly what I do!!
    > I do it in C#, but exactly the same, and I can only see
    > the Initial Values. I've also seen another sample which
    > works, but mine doesn't!!?!
    >
    > Anybody got a hint??
    >
    > - P L E A S E ! -
    >
    > >-----Original Message-----
    > >Hi Sebi,
    > >
    > >I created a sample grid with checkboxes. I can check &

    > uncheck the boxes
    > >and submit the form. It will list back to me (correctly)

    > which boxes are
    > >checked or not. I think this sample may help you.
    > >
    > >Add a grid & a button. Set the grid to have one template

    > column with a
    > >check box in it.
    > >
    > >Here's my HTML
    > >
    > ><form id="Form1" method="post" runat="server">
    > > <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101;

    > LEFT: 16px; POSITION:
    > >absolute; TOP: 57px" runat="server"
    > > AutoGenerateColumns="False">
    > > <Columns>
    > > <asp:TemplateColumn>
    > > <ItemTemplate>
    > > <asp:CheckBox id="CheckBox1"

    > runat="server"></asp:CheckBox>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > > </Columns>
    > > </asp:DataGrid>
    > > <asp:Button id="Button1" style="Z-INDEX: 102; LEFT:

    > 8px; POSITION:
    > >absolute; TOP: 8px" runat="server"
    > > Text="Button"></asp:Button>
    > ></form>
    > >
    > >
    > >
    > >Next, my code-behind is very simple. It's all in the

    > page_load.
    > >
    > >Private Sub Page_Load(ByVal sender As System.Object,

    > ByVal e As
    > >System.EventArgs) Handles MyBase.Load
    > > 'Force "flow" layout
    > > DataGrid1.Attributes.Remove("style")
    > > Button1.Attributes.Remove("style")
    > >
    > > If Not Page.IsPostBack Then
    > > Dim MyList As New ArrayList
    > > Dim i As Int32
    > > For i = 0 To 3
    > > MyList.Add(i)
    > > Next
    > > DataGrid1.DataSource = MyList
    > > DataGrid1.DataBind()
    > > Else
    > > Dim i As Int32
    > > For i = 0 To DataGrid1.Items.Count - 1
    > > Dim ck As CheckBox
    > > ck = DataGrid1.Items(i).Cells(0).FindControl

    > ("CheckBox1")
    > > Response.Write(ck.Checked & "<br>")
    > > 'add code here to select or deselect all
    > > 'update the database here
    > > Next
    > > End If
    > >End Sub
    > >
    > >
    > >Thank you, Mike
    > >Microsoft, ASP.NET Support Professional
    > >
    > >Microsoft highly recommends to all of our customers

    > that they visit the
    > >http://www.microsoft.com/protect site and perform the

    > three straightforward
    > >steps listed to improve your computer's security.
    > >
    > >This posting is provided "AS IS", with no warranties,

    > and confers no rights.
    > >
    > >
    > >--------------------
    > >> Content-Class: urn:content-classes:message
    > >> From: "Sebi" <>
    > >> Sender: "Sebi" <>
    > >> Subject: 'Overall' Editing DataGrids
    > >> Date: Tue, 11 Nov 2003 08:38:05 -0800
    > >> Lines: 22
    > >> Message-ID: <125d01c3a872$2e457d70$>
    > >> MIME-Version: 1.0
    > >> Content-Type: text/plain;
    > >> charset="iso-8859-1"
    > >> Content-Transfer-Encoding: 7bit
    > >> X-Newsreader: Microsoft CDO for Windows 2000
    > >> Thread-Index: AcOoci5FF7BRb9OBSVa+nWc4+8DI0g==
    > >> X-MimeOLE: Produced By Microsoft MimeOLE

    > V5.50.4910.0300
    > >> Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >> Path: cpmsftngxa06.phx.gbl
    > >> Xref: cpmsftngxa06.phx.gbl

    > microsoft.public.dotnet.framework.aspnet:190088
    > >> NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    > >> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > >>
    > >> Hello All,
    > >>
    > >> I'm using DataGrids mainly to display Data.
    > >> Now it should be possible for some Flags to be edited.
    > >> For this reason I've added CheckBoxes to the DataGrid.
    > >>
    > >> I don't want to add edit & update button.
    > >> I want to do a Global update including a
    > >> SelectAll/DeselectAll.
    > >>
    > >> The Problem is, that the Values don't seem to be

    > updated.
    > >> When I read the Checked Flag of the Checkbox, it still
    > >> contains the Initial Value.
    > >>
    > >> Is there some Command like UpdateData(false)?
    > >> Or is there a Property that I might have set wrong?
    > >> Any Other Ideas how I can read the WebPage Values?
    > >>
    > >> Thanks a lot for any help
    > >>
    > >> Sebi
    > >>
    > >>

    > >
    > >.
    > >

    >
     
    Mike Moore [MSFT], Nov 12, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Ritchie

    Best overall reporting package?

    Paul Ritchie, Aug 14, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    2,836
    dotnetdev18
    Oct 27, 2008
  2. Sebi

    Overall editing DataGrids

    Sebi, Nov 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    355
  3. Alan Silver
    Replies:
    20
    Views:
    2,188
    Alan Silver
    Nov 1, 2005
  4. dew

    Editing datagrids & scrolling problem

    dew, Feb 14, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    143
  5. subha

    Editing in nested datagrids - ASP.NET and VB

    subha, Jul 10, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    141
    subha
    Jul 10, 2003
Loading...

Share This Page