Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 1st, 2004, 01:25 AM
Authorized User
Join Date: Jul 2004
Location: delhi, , India.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using check boxes in datagrid

   i am facing a problem with the checkboxes displayed in the datagrid.when the data are displayed, one of the columns has the checkboxes.Now i want that when i select some checkboxes, the rows corresponding to those selected, should be updated or deleted. I tried this using datagriditem and using a loop to search the entire data. But how can i get the value of the checkboxes to see whether it is clicked or not ? Please give some idea.

Reply With Quote
  #2 (permalink)  
Old September 8th, 2004, 01:33 AM
Authorized User
Join Date: Jul 2004
Location: delhi, , India.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts

Hi again, this time i am sending my codings with this. Look at it and say what is the problem with this.I hope this time i will get a reply.

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

        Dim con As SqlConnection
        Dim cmd1, cmd2 As SqlCommand
        Dim qry1, qry2 As String

        con = New SqlConnection("server= cabin61;uid=sa;pwd=;database=ab")
        qry1 = "select rollno,name from chkbtry "
         cmd1 = New SqlCommand(qry1, con)
         DataGrid1.DataSource = cmd1.ExecuteReader()
    End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myDataGridItem As DataGridItem

        Dim chkSelected As System.Web.UI.WebControls.CheckBox

        Dim strStoreName As String

        Dim strStoreID As String
        Dim conn As SqlConnection
        Dim cmd3, cmd4 As SqlCommand
        Dim qry, qry2 As String
        Dim sqldrd As SqlDataReader
        For Each myDataGridItem In DataGrid1.Items
            chkSelected = myDataGridItem.FindControl("chkSelection")

           If chkSelected.Checked = True Then
        conn = New SqlConnection("server= cabin61;uid=sa;pwd=;database=ab")
        qry = "update chkbtry set name = '" & TextBox1.Text & "' where rollno=4"
        cmd3 = New SqlCommand(qry, conn)
         End If
    End Sub
End Class

<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 286px; POSITION: absolute; TOP: 157px" runat="server" AutoGenerateColumns="False" SelectedIndex="0">
                    <asp:TemplateColumn HeaderText="RollNo">
                        <HeaderStyle Font-Names="Bookman Old Style" ForeColor="Black" BackColor="White"></HeaderStyle>
                            <asp:CheckBox ID="ChkSelection" Runat="server"></asp:CheckBox>
                            <asp:Label ID="hypDetails" Text='<%#DataBinder.Eval(Container.DataItem, "rollno")%>' runat="server">
                    <asp:TemplateColumn HeaderText="Name">
                        <HeaderStyle Font-Names="Bookman Old Style" ForeColor="Black" BackColor="White"></HeaderStyle>
                            <asp:Label ID ="lbl1" Text='<%#DataBinder.Eval(Container.DataItem, "name")%>' runat="server">
            </asp:datagrid><asp:button id="Button1" style="Z-INDEX: 102; LEFT: 330px; POSITION: absolute; TOP: 336px" runat="server" Text="Enter"></asp:button><asp:label id="lblstatus1" style="Z-INDEX: 103; LEFT: 221px; POSITION: absolute; TOP: 393px" runat="server" Height="56px" Width="440px"></asp:label>
            <asp:TextBox id="TextBox1" style="Z-INDEX: 104; LEFT: 289px; POSITION: absolute; TOP: 81px" runat="server"></asp:TextBox></form>

I dont know where the problem is. Even no error message is comign but the data are not updated also.Please help.

Reply With Quote
  #3 (permalink)  
Old September 8th, 2004, 08:28 AM
Friend of Wrox
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post

Hello ractim,
Have a look at this thread
Hope this helps.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop over check boxes sams ASP.NET 1.0 and 1.1 Professional 5 July 17th, 2007 06:26 AM
Check Boxes Allan320 Access VBA 3 June 2nd, 2006 05:45 AM
Using check boxes to filter dstein4d Access VBA 13 January 25th, 2006 07:50 PM
Disable Check Boxes sweet4511 VB How-To 22 July 19th, 2005 03:53 PM
Getting value of Dynamic Check boxes kathryne Classic ASP Databases 3 March 19th, 2004 05:44 AM

All times are GMT -4. The time now is 08:12 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.