I am attempting to use a checkbox in a grid. I know there are many posts on this tompic but I just can't seem to get the checked values to work for me.
Here is my code:
The goal is for me to pass either a 1 or a 0 to a SQL Stored Procedure. I just can't seem to pass the correct parameter. I am not set on using a Session Variable. Any way I can get the 0 or the 1 to the @PermSelect variable is good by me.
Here is my code:
Protected
Sub
btn_ModifyPerms_Click(sender
As
Object
, e
As
System.EventArgs)
For
Each
grdItem
As
GridDataItem
In
rgd_TaskPermissions.Items
Dim
cbx_Select
As
CheckBox =
DirectCast
(grdItem.FindControl(
"cbx_Select"
), CheckBox)
'Do Something
If
cbx_Select.Checked =
False
Then
Session(
"PermSelect"
) = 0
Else
Session(
"PermSelect"
) = 1
End
If
Dim
DatabaseName
As
String
= Session(
"DBName"
)
Dim
Table
As
String
= Session(
"Table"
)
Dim
TaskRole
As
String
= Session(
"TaskRole"
)
Dim
connectionString =
New
SqlConnection(
"server=DO-IT-AB\MSSQLAB;database=AeriesAdmin;UID=itc.sysadmin;PWD=m1s.@dm1n6;"
)
Dim
command =
New
SqlCommand(
"aa_task_table_permissions_select"
, connectionString)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(
"@dbname"
, SqlDbType.VarChar).Value = DatabaseName
command.Parameters.Add(
"@Table"
, SqlDbType.VarChar).Value = Table
command.Parameters.Add(
"@TaskRole"
, SqlDbType.VarChar).Value = Session(
"TaskRole"
)
command.Parameters.Add(
"@PermSelect"
, SqlDbType.Int).Value = Session(
"PermSelect"
)
command.Connection.Open()
command.ExecuteNonQuery()
command.Connection.Close()
Next
End
Sub
The goal is for me to pass either a 1 or a 0 to a SQL Stored Procedure. I just can't seem to pass the correct parameter. I am not set on using a Session Variable. Any way I can get the 0 or the 1 to the @PermSelect variable is good by me.