Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 Display Modes
  #1 (permalink)  
Old September 19th, 2006, 11:02 AM
Authorized User
 
Join Date: Sep 2006
Location: chennai, tamilnadu, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accept and Delete a row in DataGrid

Hi ,
                     This is my datagrid code in which drag-drop accept and delete buttons ie,, cmdDelete and cmdAccept are not working.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim strRowId As String
            Dim strOption As String
            strOption = Request.QueryString("option")
            If strOption = "" Then
                DataBind1()
            ElseIf strOption = "Accept" Then
                strRowId = Request.QueryString("rowid")
                strConnString = objCsLgateway.GetConnectionString()
                conn = objCsDataBase.GetDbConnection(strConnString)
                mycommand = New SqlCommand("update tblLogos set status =1 where row_id=" & strRowId, conn)
                mycommand.ExecuteNonQuery()
                Response.Redirect("LogosbyUsers.aspx", True)
            ElseIf strOption = "Delete" Then
                strRowId = Request.QueryString("rowid")
                strConnString = objCsLgateway.GetConnectionString()
                conn = objCsDataBase.GetDbConnection(strConnString)
                mycommand = New SqlCommand("delete tblLogos where row_id=" & strRowId, conn)
                mycommand.ExecuteNonQuery()
                Response.Redirect("LogosbyUsers.aspx", True)
            Else
                DataBind1()
            End If
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub
    Sub DataBind1()
        Try
            strConnString = objCsLgateway.GetConnectionString()
            conn = objCsDataBase.GetDbConnection(strConnString)
            Dim adap As New SqlDataAdapter("select * from tblLogos where status=0", conn)
            Dim ds As New DataSet
            adap.Fill(ds, "tblLogos")
            DataGrid1.DataSource = ds
            DataGrid1.DataBind()
        Catch errEx As Exception
            Response.Write(errEx.Message)
        Finally
            objCsDataBase.CloseDbConnection(conn)
        End Try
    End Sub
    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
                  Dim objItem As DataGridItem
            For Each objItem In DataGrid1.Items
                If objItem.ItemType <> ListItemType.Header And objItem.ItemType <> ListItemType.Footer And objItem.ItemType <> ListItemType.Pager Then
                    Dim ChkGet1 As Boolean
                    Dim strRowId
                    ChkGet1 = CType(objItem.Cells(0).FindControl("chkget"), CheckBox).Checked
                    strRowId = CType(objItem.FindControl("row_id"), Label).Text
                    If ChkGet1 = True Then
                        strConnString = objCsLgateway.GetConnectionString()
                        conn = objCsDataBase.GetDbConnection(strConnString)
                        mycommand = New SqlCommand("delete from tblLogos where row_id=" & strRowId, conn)
                        mycommand.ExecuteNonQuery()
                    End If
                End If
            Next
            DataBind1()
            End Sub
    Private Sub cmdAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAccept.Click
                Dim objItem As DataGridItem
            For Each objItem In DataGrid1.Items
                If objItem.ItemType <> ListItemType.Header And objItem.ItemType <> ListItemType.Footer And objItem.ItemType <> ListItemType.Pager Then
                    Dim ChkGet1 As Boolean
                    Dim strRowId
                    ChkGet1 = CType(objItem.Cells(1).FindControl("chkget"), CheckBox).Checked()
                    strRowId = CType(objItem.FindControl("row_id"), Label).Text
                    If ChkGet1 = True Then
                        strConnString = objCsLgateway.GetConnectionString()
                        conn = objCsDataBase.GetDbConnection(strConnString)
                        mycommand = New SqlCommand("update tblLogos set status =1 where row_id=" & strRowId, conn)
                        mycommand.ExecuteNonQuery()
                    End If
                End If
            Next
            DataBind1()
           End Sub
pls read the entire code and help me in rectifying my error.
 Regards
Vijayarajan.V

  #2 (permalink)  
Old September 19th, 2006, 11:29 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

why do you have that code in the page_load? your delete and accept functions should be handled through the various methods.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
  #3 (permalink)  
Old September 19th, 2006, 12:15 PM
Authorized User
 
Join Date: Sep 2006
Location: chennai, tamilnadu, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

     Thanks for replying. but in my datagrid i have 2 accept and delete buttons.one accept and one delete hyperlink buttons are bound to datagrid and another one delete and accept are drag and drop controls. hyperlink buttons are used for deleting and accepting single row and drag-drop controls are used for deleting and accepting multiselect checkboxes. In that hyperlink controls are working properly. but the chkGet command in cmdDelete and cmdAccept are showing false although checked in F11. For that i need our help and suggestions.

Thanx in Advance
Vijay

 


Thread Tools
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
To delete and Accept a row in DataGrid vijay_83 ASP.NET 1.0 and 1.1 Basics 3 September 19th, 2006 02:15 PM
how delete row in datagrid which check checkbox ashish2001mca Forum and Wrox.com Feedback 1 September 18th, 2005 03:43 AM
Confirm delete row in datagrid rajanikrishna General .NET 3 December 8th, 2004 08:27 PM
how to delete a row when click delete hyperlink naveenkumarg1 Pro JSP 1 August 16th, 2004 01:29 AM
Manage data row by row in datagrid Dragonist Classic ASP Databases 5 July 29th, 2004 04:17 AM



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


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