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

W

Wolffang

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
-------------------------------------------------------------------------------------
 
W

Wolffang

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top