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

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 3448

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: 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...
0
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...
0
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 ...
14
DJRhino1175
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...
0
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...
0
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=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
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.