472,805 Members | 938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Gridview,CheckboxList and ObjectDataSource


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:

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

How can I loop through the items and select them?
<asp:checkboxlist id="ChkWeekDays" runat="Server"

datavaluefield="WeekDays" ondatabound="Preselect_Checkbox"

repeatdirection="Vertical" style="float: left">



asp:objectdatasource deletemethod="DeletePrescriptionDetails"

id="objDetails" runat="server" selectmethod="GetAllPrescriptionDetails"



<asp:controlparameter controlid="hdnPresID" name="PrescriptionID"

type="Int32" />



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)


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


End While



If userList IsNot Nothing AndAlso userList.Count 0 Then

Return userList


Return Nothing

End If

End Function

Nov 15 '06 #1
0 3448

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

Similar topics

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....
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...
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...
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...
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...
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...
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...
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...
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...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.