473,472 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Gridview,CheckboxList and ObjectDataSource

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:objectdatasource 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:objectdatasource>
______________________________________________

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("PrescriptionDet ailId"), 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

Nov 15 '06 #1
0 3489

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: rob | last post by:
Here is my scenario: One of my aspx pages has a CheckBoxList (Item1, Item2) and a GridView. Then I have a database that has the columns Item1 and Item2 (among others) with the data type bit....
0
by: Eiriken | last post by:
Hello everyone, I am using ASP.NET 2 and trying to bind a objectdatasource to a gridview. By doing this the most common way by adding an objectdatasource to the page and by using the wizard to...
1
by: syl | last post by:
Hello I am trying to create a "easy to use" gridview with filters (dropdownlist in headers), sorting...and much more.... In order to do that, i prefer to use a objectdatasource (ODS) beacause...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
3
by: pblack9455 | last post by:
I have a simple requirement to bind a small ArrayList of (ItemLine) Objects to a GridView control. The Gridview renders on the page and allows me to click update/edit buttons...however the data...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
0
by: mutt1170 | last post by:
I have a checkbox list nested inside a gridview. The gridview pulls its data from an objectdatasource and lists countries. The nested checkbox list is databound to another object datasource and...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.