asp:DataList CheckBox Multi-Update

I have a Datalist with some data and a simple checkbox. I want it to be used to update a BIT value in my database for that row of data.  Using a button on the page.

I can't seem to get passed the EVENT FIRING haha

I am not sure what I am doing wrong, But what I do want to do Is update the database for each box that is checked with the value true!

Help!


<div id="Inbox" class="container">
 <table width="500" border="1">
 <tr>
<td valign="top" width="300" height="50" colspan="2">
 
 
    <asp:Button ID="DeleteButton" runat="server" Text="Delete Selected" />
 
 
<asp:DataList id="InboxRepeater" runat="server" EnableViewState="False" Width="400px" OnDeleteCommand="UserDeleteThread">     
    <HeaderTemplate>
    <tr>
        <td colspan="2"><asp:Label ID="RealNameLabel" runat="server" Text="Name: " Font-Bold="true"/></td>
        <td> <asp:Label ID="SentLabel" runat="server" Text="Sent: " Font-Bold="true"/></td>                   
        <td><asp:Label ID="Label2" runat="server" Text="Subject: " Font-Bold="true"/></td>
    </tr>
    </HeaderTemplate>
 
    <ItemTemplate>
                    <tr>
                        <td>
                        <a href="/Messages/ReadThread.aspx?ThreadID=<%# DataBinder.Eval(Container.DataItem, "ThreadId") %>&FriendID=<%# DataBinder.Eval(Container.DataItem, "SenderId") %>">
                        <img src="/Profile/DisplayUserThumb.aspx?UserId=<%# DataBinder.Eval(Container.DataItem, "SenderId") %>" 
                            alt="<%# DataBinder.Eval(Container.DataItem, "RealName") %>" width="50" /></a>                    
                        </td>
                        <td> 
                        <asp:CheckBox runat="server" Checked="false"/>
                        </td>
                        <td>
                        
                        <%#DataBinder.Eval(Container.DataItem, "RealName")%>
                        </td>
                        <td>
                        <%#DataBinder.Eval(Container.DataItem, "TimeSent")%>                      
                        </td>
                        <td>
                        <%#DataBinder.Eval(Container.DataItem, "Subject")%>
                        </td>
                        
                    </tr>
 
 
                
                
    </ItemTemplate>
 
</asp:DataList>
 
</td>
</tr>
</table>
 
    
</div>
 
 
------ fill datalist
 
Dim adapter As New SqlDataAdapter
 
                Try
                    Dim InboxSelectResultSet As New DataSet
 
                    'Connection
                    Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("AGConnectionString").ConnectionString)
 
                        Using myCommand As New SqlCommand("AGInboxSelect", myConnection)
 
 
                            myCommand.CommandType = CommandType.StoredProcedure
                            myCommand.Parameters.AddWithValue("@UserID", CurrentUser)
 
                            myConnection.Open()
 
                            Using da As New SqlDataAdapter("AGInboxSelect", myConnection)
                                da.SelectCommand = myCommand
                                da.Fill(InboxSelectResultSet)
                            End Using
 
                            myConnection.Close()
                        End Using
 
 
                        'ASP Repeater with an Id of "InboxRepeater"
                        Me.InboxRepeater.DataSource = InboxSelectResultSet.Tables(0)
                        Me.InboxRepeater.DataBind()
 
                    End Using
                Catch ex As Exception
                    'do something
                End Try
 
--- delete sub
 
    Sub UserDeleteThread(ByVal sender As Object, _
                   ByVal e As DataListCommandEventArgs)
 
        Server.Transfer("UpdateConfirm.aspx")
    End Sub

Open in new window

LVL 1
HarleySkaterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

prairiedogCommented:
>>>I can't seem to get passed the EVENT FIRING haha
Do you mean the UserDeleteThread is not firing when you click the delete button?
0
HarleySkaterAuthor Commented:
it does a postback, but in the behind code it never touches the UserDeleteThread sub
0
HarleySkaterAuthor Commented:
basicly I don't care how it happens hahah, but I want to have a set of records, that displays on the page, from a really tricky stored procedure.
Then I want to be able to allow the people to looking at that page to check the boxes in the page and then update that checkbox value for those rows to the server.

I keep running into problems because I have to pass the UserId for that use into the the stored procedure.

I have started from scratch on this like 5 times.
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

HarleySkaterAuthor Commented:
I really don't care if its gridview, datalist or whatever as long as it can just allow me to use this stored procedure and allow me to update !!!!
0
prairiedogCommented:
Your event handler has wrong signature. Did you create the event handler manually yourself?
0
HarleySkaterAuthor Commented:
I double clicked the button I had in my datalist, not the button that was above the datalist that I added later.  I seriously did start over on this like 5 times.  Hahaha I think I am just going to restart this topic here.
------ page code
 
<div id="Inbox" class="container">
 <table width="500" border="1">
 <tr>
<td valign="top" width="300" height="50" colspan="2">
 
 
    <asp:GridView ID="InboxGridView" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ThreadId" 
        EmptyDataText="There are no data records to display.">
        <Columns>
            <asp:BoundField DataField="ThreadId" HeaderText="ThreadId" ReadOnly="True" 
                SortExpression="ThreadId" />
            <asp:BoundField DataField="SenderId" HeaderText="SenderId" 
                SortExpression="SenderId" />
            <asp:BoundField DataField="RecipientId" HeaderText="RecipientId" 
                SortExpression="RecipientId" />
            <asp:CheckBoxField DataField="SenderDelete" HeaderText="SenderDelete" 
                SortExpression="SenderDelete" />
            <asp:CheckBoxField DataField="RecipientDelete" HeaderText="RecipientDelete" 
                SortExpression="RecipientDelete" />                
            <asp:BoundField DataField="Subject" HeaderText="Subject" 
                SortExpression="Subject" />
            <asp:BoundField DataField="RealName" HeaderText="Name" 
                SortExpression="RealName" />
        </Columns>
    </asp:GridView>
 
</td>
</tr>
</table>
 
    
</div>
 
------ behind code
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        If Not IsPostBack Then
 
            If User.Identity.IsAuthenticated Then
 
                CurrentUser = Membership.GetUser().ProviderUserKey.ToString()
 
                Dim adapter As New SqlDataAdapter
 
                Try
                    Dim InboxSelectResultSet As New DataSet
 
                    'You should really considering moving data access and most logic into their own layers.
                    Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("AGConnectionString").ConnectionString)
 
                        Using myCommand As New SqlCommand("AGInboxSelect", myConnection)
 
 
                            myCommand.CommandType = CommandType.StoredProcedure
                            myCommand.Parameters.AddWithValue("@UserID", CurrentUser)
 
                            myConnection.Open()
 
                            Using da As New SqlDataAdapter("AGInboxSelect", myConnection)
                                da.SelectCommand = myCommand
                                da.Fill(InboxSelectResultSet)
                            End Using
 
                            myConnection.Close()
                        End Using
 
 
                        'ASP Repeater with an Id of "InboxRepeater"
                        Me.InboxGridView.DataSource = InboxSelectResultSet.Tables(0)
                        Me.InboxGridView.DataBind()
 
                    End Using
                Catch ex As Exception
                    'do something
                End Try
 
 
            Else
                Server.Transfer("~/default.aspx")
                Exit Sub
            End If
        End If
 
    End Sub

Open in new window

0
HarleySkaterAuthor Commented:
gerrrrrrrrr I mean the page code should be this.
-------- Page code
 
<div id="Inbox" class="container">
 <table width="500" border="1">
 <tr>
<td valign="top" width="300" height="50" colspan="2">
 
 
    <asp:GridView ID="InboxGridView" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ThreadId" 
        EmptyDataText="There are no data records to display.">
        <Columns> 
            <asp:CheckBoxField HeaderText="Delete" />                    
            <asp:BoundField DataField="ThreadId" HeaderText="ThreadId" ReadOnly="True" 
                SortExpression="ThreadId" />
            <asp:BoundField DataField="SenderId" HeaderText="SenderId" 
                SortExpression="SenderId" />
            <asp:BoundField DataField="RecipientId" HeaderText="RecipientId" 
                SortExpression="RecipientId" />           
            <asp:BoundField DataField="Subject" HeaderText="Subject" 
                SortExpression="Subject" />
            <asp:BoundField DataField="RealName" HeaderText="Name" 
                SortExpression="RealName" />
        </Columns>
    </asp:GridView>
 
</td>
</tr>
</table>
 
    
</div>

Open in new window

0
prairiedogCommented:
So it seems you decided to use GridView and it is ok. I think I can help you with this, but don't change your mind in 5 minutes.
With mutiple update in your case, you need a button outside the GridView. Then in the Button's click event handler, you need to loop through the GridView and find the row that checked, then do the update.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HarleySkaterAuthor Commented:
I know right!, Im spazzing OUT hahaha

OK i am trying that NOW :D
0
HarleySkaterAuthor Commented:
got it !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.