store procedure

Hi, its friday evening  and i have got to do this!!!

I have a datagrid and the usual update, delete etc buttons. Now how can i update a get the update function to work. basically I need to call a store procedure which is in my "Access.vb class"

this is the Stored procedure in the Access.vb
====================================
Public Sub UpdateSection(ByVal SectionName As String)
            Dim DL As New DataLayer
            Dim sqlparams As New ArrayList
            sqlparams.Add(Dl.AddParameter("@SectionName", "SqlDbType.NVarChar", 50, SectionName, ParameterDirection.Input))
            Try
                DL.ExecuteStoredProc("spUpdateSection", sqlparams)
            Catch ex As Exception
                Throw New ArgumentException(ex.Message.ToString())
            End Try
        End Sub
===============================================
and in my grid codebehind this is where i am trying to call the store procedure
===========================================================
Public Sub OnUpdate(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
        'initialize to update the datagrid ctrl

        Dim item As String = CType(e.Item.FindControls("txtsectionname"), TextBox).Text()
        Dim updater As New Sections
      =====================================================
txtsectionname is from this----

<EditItemTemplate>
                                                      <asp:TextBox Runat="server" ID="txtSectionName" Text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"SectionName"))%>' Width="150"/>
                                                </EditItemTemplate>

pls help,
thanks
SirReadAlotAsked:
Who is Participating?
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.

Ramesh SrinivasTechnical ConsultantCommented:
Hmmm. not familiar with using the DataLayer type.

I do not see in your datagrid codebehind any code referencing the sub UpdateSection.

Sorry, not much help i know.

KS
0
SirReadAlotAuthor Commented:
cool!!
0
MikeMCSDCommented:
add this button:

<asp:Button ID="lnkAdd" Runat=server Text="Update"  CommandName="UpdateAccess" ></asp:Button>

then add this event:

Private Sub grid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grid.ItemCommand

        If e.CommandName = "UpdateAccess" Then

        UpdateSection.UpdateSection(SectionName)
.. ..

if you have other commands, list them here and check the e.CommandName value
for the one clicked.

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

SirReadAlotAuthor Commented:
thanks mike
i shall try on monday!!
0
MikeMCSDCommented:
Sir, forget that last post . . I think you want something more like this:

Public Sub OnUpdate(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
        'initialize to update the datagrid ctrl

        Dim item As String = CType(e.Item.FindControls("txtsectionname"), TextBox).Text()

        Access.UpdateSection(item)

       'then bind the data to the grid again here . . .

       
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
SirReadAlotAuthor Commented:
okay, am trying it now
0
SirReadAlotAuthor Commented:
thanks for the tip,

for those interested, this is what i did

Public Sub OnUpdate(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
        'initialize to update the datagrid ctrl
        Dim item As String = CType(e.Item.FindControl("txtSectionName"), TextBox).Text()
        Dim Update As New Sections
        Update.UpdateSection(dgSection.DataKeys(e.Item.ItemIndex), item)
        dgSection.EditItemIndex = -1
        BindGrid()
    End Sub
---------------------------------------this is the stored procedure
Public Function UpdateSection(ByVal SectionID As Integer, ByVal SectionName As String)
            Dim DL As New DataLayer
            Dim sqlparams As New ArrayList
            sqlparams.Add(DL.AddParameter("@SectionID", "SqlDbType.Int", 4, SectionID, ParameterDirection.Input))
            sqlparams.Add(DL.AddParameter("@SectionName", "SqlDbType.NVarChar", 50, SectionName, ParameterDirection.Input))
            Try
                DL.ExecuteStoredProc("spUpdateSection", sqlparams)
            Catch ex As Exception
                Throw New ArgumentException(ex.Message.ToString())
            End Try
        End Function

thanks
SirReadAlot
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.