A
avital
Hi,
Hope someone can please help.
I have a Gridview with a checkboxlist. On edititemTemplate I want the
checkboxlist items to be selected as returned from the database.
In the database I have a table called PrescriptionDetails with a field
called Weekdays that can store data in the following format:
Monday,Tuesday,Thursday,
I have a function called GetAllPrescriptionDetails that returns the
data in the database.
When the Gridview is in Edit mode I want the checkboxlist to select the
items so if there are the values Monday and Tuesday then the Monday
item will be selected and the Tuesday item. Also the values are stored
with a , in the database so I need to split the values. I am using an
objectDataSource.
How can I loop through the items and select them?
<asp:checkboxlist id="ChkWeekDays" runat="Server"
datatextfield="WeekDays"
datavaluefield="WeekDays" ondatabound="Preselect_Checkbox"
repeatcolumns="2"
repeatdirection="Vertical" style="float: left">
</asp:checkboxlist>
_______________-
<
asp
bjectdatasource deletemethod="DeletePrescriptionDetails"
insertmethod="InsertPrescriptionDetails"
id="objDetails" runat="server" selectmethod="GetAllPrescriptionDetails"
updatemethod="UpdatePrescriptionDetails"
typename="GridViewClasses">
<selectparameters>
<asp:controlparameter controlid="hdnPresID" name="PrescriptionID"
propertyname="Value"
type="Int32" />
</selectparameters>
</asp
bjectdatasource>
______________________________________________
Public Function GetAllPrescriptionDetails(ByVal PrescriptionId As
Integer) As List(Of GridViewClasses)
Dim userList As New List(Of GridViewClasses)()
Dim myCommand As New SqlCommand("GetPrescriptionDetails", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.AddWithValue("@PrescriptionID", PrescriptionId)
myConnection.Open()
Dim reader As SqlDataReader = myCommand.ExecuteReader()
While reader.Read()
Dim user As New
GridViewClasses(DirectCast(reader("PrescriptionDetailId"), Integer),
DirectCast(reader("PrescriptionId"), Integer),
DirectCast(reader("MedicineId"), Integer),
DirectCast(reader("MedicineGenericName"), String),
DirectCast(reader("RouteId"), Integer), DirectCast(reader("RouteName"),
String), DirectCast(reader("InfusionVolumeTitle"), String),
DirectCast(reader("InfusionRate"), Integer),
DirectCast(reader("ActualDose"), Integer),
DirectCast(reader("InfusionVolumeID"), Integer),
DirectCast(reader("Weekdays"), String),
DirectCast(reader("PrescriptionDate"), DateTime))
userList.Add(user)
End While
myConnection.Close()
reader.Close()
myCommand.Dispose()
If userList IsNot Nothing AndAlso userList.Count > 0 Then
Return userList
Else
Return Nothing
End If
End Function
Hope someone can please help.
I have a Gridview with a checkboxlist. On edititemTemplate I want the
checkboxlist items to be selected as returned from the database.
In the database I have a table called PrescriptionDetails with a field
called Weekdays that can store data in the following format:
Monday,Tuesday,Thursday,
I have a function called GetAllPrescriptionDetails that returns the
data in the database.
When the Gridview is in Edit mode I want the checkboxlist to select the
items so if there are the values Monday and Tuesday then the Monday
item will be selected and the Tuesday item. Also the values are stored
with a , in the database so I need to split the values. I am using an
objectDataSource.
How can I loop through the items and select them?
<asp:checkboxlist id="ChkWeekDays" runat="Server"
datatextfield="WeekDays"
datavaluefield="WeekDays" ondatabound="Preselect_Checkbox"
repeatcolumns="2"
repeatdirection="Vertical" style="float: left">
</asp:checkboxlist>
_______________-
<
asp
![Blush :o :o](/styles/default/custom/smilies/blush.gif)
insertmethod="InsertPrescriptionDetails"
id="objDetails" runat="server" selectmethod="GetAllPrescriptionDetails"
updatemethod="UpdatePrescriptionDetails"
typename="GridViewClasses">
<selectparameters>
<asp:controlparameter controlid="hdnPresID" name="PrescriptionID"
propertyname="Value"
type="Int32" />
</selectparameters>
</asp
![Blush :o :o](/styles/default/custom/smilies/blush.gif)
______________________________________________
Public Function GetAllPrescriptionDetails(ByVal PrescriptionId As
Integer) As List(Of GridViewClasses)
Dim userList As New List(Of GridViewClasses)()
Dim myCommand As New SqlCommand("GetPrescriptionDetails", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.AddWithValue("@PrescriptionID", PrescriptionId)
myConnection.Open()
Dim reader As SqlDataReader = myCommand.ExecuteReader()
While reader.Read()
Dim user As New
GridViewClasses(DirectCast(reader("PrescriptionDetailId"), Integer),
DirectCast(reader("PrescriptionId"), Integer),
DirectCast(reader("MedicineId"), Integer),
DirectCast(reader("MedicineGenericName"), String),
DirectCast(reader("RouteId"), Integer), DirectCast(reader("RouteName"),
String), DirectCast(reader("InfusionVolumeTitle"), String),
DirectCast(reader("InfusionRate"), Integer),
DirectCast(reader("ActualDose"), Integer),
DirectCast(reader("InfusionVolumeID"), Integer),
DirectCast(reader("Weekdays"), String),
DirectCast(reader("PrescriptionDate"), DateTime))
userList.Add(user)
End While
myConnection.Close()
reader.Close()
myCommand.Dispose()
If userList IsNot Nothing AndAlso userList.Count > 0 Then
Return userList
Else
Return Nothing
End If
End Function