Passing variables from datagrid to codebehind... help needed!!!!

Discussion in 'ASP .Net Web Controls' started by Wolffang, Nov 7, 2004.

  1. Wolffang

    Wolffang Guest

    I have a column in a datagrid which is OrderID. I am trying to pass its
    values when rows are clicked to code in my codebehind that will update my
    database via the database... i have tried to convert the value to a label in
    my aspx page, so i can read its value... maybe this is wrong... any one have
    any other ideas???

    SQL profiler states :
    exec dbo.[USP_Admin_Update_UserProcessLock] @OrderID = N'', @AdminUserName =
    N'Admin', @AdminProcess = 1
    so OrderID is still not being passed here....


    MY CODE.....
    -------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------
    <code behind>
    -------------------------------------------------------------------------------------
    Dim dg As DataGridItem
    Dim ck As CheckBox
    Dim OrdID As Label
    Me.SqlConnection1.Open()
    For Each dg In dgOrders.Items
    ck = dg.FindControl("chkSelect")
    OrdID = dg.FindControl("Label1")
    If ck.Checked = True Then
    Me.SqlCommand1.Parameters("@OrderID").Value = OrdID.Text
    Me.SqlCommand1.Parameters("@AdminUserName").Value = lblUserName.Text
    Me.SqlCommand1.Parameters("@AdminProcess").Value = 1
    Me.SqlCommand1.ExecuteNonQuery()
    End If
    Next
    Me.SqlConnection1.Close()

    -------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------
    <ASPX>
    -------------------------------------------------------------------------------------
    <HeaderTemplate>
    <asp:CheckBox id="chkAll"
    onclick="javascript:SelectAllCheckboxes(this);" runat="server"
    AutoPostBack="false"
    ToolTip="Select/Deselect All" />
    </HeaderTemplate>
    <ItemTemplate>
    <asp:CheckBox id="chkSelect"
    onclick="javascript:HighlightRow(this);" runat="server"
    OnCheckedChanged="dgOrders_CheckedChanged"
    AutoPostBack="false" Enabled="True" />
    <asp:Label id="Label1" runat="server">
    <%# Container.DataItem("OrderID") %>
    </asp:Label>
    </ItemTemplate>


    -------------------------------------------------------------------------------------
    -------------------------------------------------------------------------------------
    <SQL stored Procedure...>
    -------------------------------------------------------------------------------------

    CREATE PROCEDURE USP_Admin_Update_UserProcessLock
    @OrderID NVARCHAR(15),
    @AdminUserName NVARCHAR(15),
    @AdminProcess BIT

    AS
    UPDATE
    tblOrderDetails
    SET
    AdminUserName = @AdminUserName,
    AdminProcess = @AdminProcess
    WHERE
    OrderID = @OrderID
    GO
    -------------------------------------------------------------------------------------
     
    Wolffang, Nov 7, 2004
    #1
    1. Advertising

  2. Scott Mitchell [MVP], Nov 7, 2004
    #2
    1. Advertising

  3. Wolffang

    Wolffang Guest

    Thanks Scott...

    I am actually doing a multiple update...
    Simply... i have a checkbox for each of the returned records... User will
    click multiple records (not a single record), they will click an update
    button which run a SQL stored procedure which sets the name of the user in a
    field and also sets the Active field to 1 for the records that are selected.

    what i am doing is simple..

    I will check the article to see if i can solve what i am doing...

    THanks

    "Scott Mitchell [MVP]" <> wrote in message
    news:...
    > Wolffgang, look at Part 6 of the Extensive Examination of the DataGrid Web
    > Control article series I have written, it details how to create an
    > editable DataGrid:
    > http://aspnet.4guysfromrolla.com/articles/071002-1.aspx
    >
    > hth
    >
    > --
    >
    > Scott Mitchell
    >
    > http://www.4GuysFromRolla.com
    > http://www.ASPMessageboard.com
    > http://www.ASPFAQs.com
    >
    > * When you think ASP, think 4GuysFromRolla.com!
     
    Wolffang, Nov 7, 2004
    #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. Kevin Spencer
    Replies:
    0
    Views:
    537
    Kevin Spencer
    Jun 27, 2003
  2. Doruk
    Replies:
    4
    Views:
    492
    Polux
    Nov 14, 2003
  3. =?Utf-8?B?UkZTNjY2?=
    Replies:
    6
    Views:
    474
    =?Utf-8?B?UkZTNjY2?=
    Oct 17, 2005
  4. =?Utf-8?B?dnZlbms=?=

    Is a Recompile needed when you change the codebehind?

    =?Utf-8?B?dnZlbms=?=, Nov 8, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    416
    =?Utf-8?B?dnZlbms=?=
    Nov 8, 2005
  5. Doruk
    Replies:
    3
    Views:
    158
    Polux
    Nov 14, 2003
Loading...

Share This Page