Hi
I need to populate a DataSource control with an id from a ddl, this
DataSource control the populates a ddl.
I have no clue how to pass the id to the DataSource control, I
have tried a few things but no luck yet.
my application is built on a 3 tier design, BL,BO,DA layers.
I'll post the code relevant for the DataSource control i'm trying
to populate.
DA: (in my DA i also have a class that holds my querystrings)
the query:Code:Public Class QueryZonesDB Public Shared strSQL Public Shared Function Zones(ByVal pid As Integer) strSQL = "SELECT " strSQL = strSQL & "idkey, " strSQL = strSQL & "project_id, " strSQL = strSQL & "userID, " strSQL = strSQL & "edited, " strSQL = strSQL & "name, " strSQL = strSQL & "description " strSQL = strSQL & "FROM tblzones " strSQL = strSQL & "WHERE idkey = " & pid & " " strSQL = strSQL & "ORDER BY name ASC" Return strSQL End FunctionBO:Code:Public Class ZonesDB Public Shared Function GetList(ByVal id As Integer) As ZonesList Dim tempList As ZonesList = Nothing 'Using Dim myConnection As MySqlConnection = New MySqlConnection(myConfig.myConnection) Try Dim myCommand = New MySqlCommand(QueryZonesDB.Zones(id), myConnection) myConnection.Open() ' Using Dim myReader As MySqlDataReader = myCommand.ExecuteReader Try If myReader.HasRows Then tempList = New ZonesList While myReader.Read tempList.Add(FillDataRecord(myReader)) End While End If myReader.Close() Finally CType(myReader, IDisposable).Dispose() End Try Finally CType(myConnection, IDisposable).Dispose() End Try Return tempList End Function Private Shared Function FillDataRecord(ByVal myDataRecord As IDataRecord) As Zones Dim myZones As Zones = New Zones myZones.Idkey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("idkey")) myZones.ProjectID = myDataRecord.GetInt32(myDataRecord.GetOrdinal("project_id")) myZones.UserID = myDataRecord.GetInt32(myDataRecord.GetOrdinal("userID")) myZones.Edited = myDataRecord.GetInt32(myDataRecord.GetOrdinal("edited")) myZones.Name = myDataRecord.GetString(myDataRecord.GetOrdinal("name")) myZones.Description = myDataRecord.GetString(myDataRecord.GetOrdinal("description")) Return myZones End Function
List collection in my BO:Code:Public Class Zones Private _idkey As Nullable(Of Integer) Private _project_id As Nullable(Of Integer) Private _user_id As Nullable(Of Integer) Private _edited_id As Nullable(Of Integer) Private _name As String = String.Empty Private _description As String = String.Empty <DataObjectFieldAttribute(True, True, False)> _ Public Property Idkey() As Integer Get Return _idkey End Get Set(ByVal value As Integer) _idkey = value End Set End Property Public Property ProjectID() As Integer Get Return _project_id End Get Set(ByVal value As Integer) _project_id = value End Set End Property Public Property UserID() As Integer Get Return _user_id End Get Set(ByVal value As Integer) _user_id = value End Set End Property Public Property Edited() As Integer Get Return _edited_id End Get Set(ByVal value As Integer) _edited_id = value End Set End Property Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Public Property Description() As String Get Return _description End Get Set(ByVal value As String) _name = value End Set End Property End Class
BL:Code:Public Class ZonesList Inherits List(Of Zones) Public Sub New() End Sub End Class
my page with the DDL and DS controls:Code:Public Class ZonesManager <DataObjectMethod(DataObjectMethodType.Select, True)> _ Public Shared Function GetList(ByVal id As Integer) As ZonesList Return ZonesDB.GetList(id) End Function
any help would be greatCode:<form id="form1" runat="server"> <div> <p> <asp:Label ID="lblWelcome" runat="server"></asp:Label> | <asp:HyperLink ID="logout" runat="server" NavigateUrl="~/Default.aspx">LogOut</asp:HyperLink> </p> </div> <div> <p> <asp:DropDownList ID="ProjectDDL" runat="server" AutoPostBack="True" DataSourceID="ProjectDataSource" DataTextField="Name" DataValueField="Idkey"> </asp:DropDownList> <asp:ObjectDataSource ID="ProjectDataSource" runat="server" DataObjectTypeName="Keith.ProjectManager.BO.Projects" DeleteMethod="Delete" InsertMethod="Save" SelectMethod="GetList" UpdateMethod="Update" TypeName="Keith.ProjectManager.Bll.ProjectsManager"> <SelectParameters> <asp:Parameter Name="id" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> </p> </div> <div> <p> <asp:Label ID="textmsg" runat="server"></asp:Label> <asp:DropDownList ID="ZonesDDL" runat="server" AutoPostBack="True" DataSourceID="ZonesDataSource" DataTextField="Name" DataValueField="Idkey" Visible="False"> <asp:ListItem>Select Here</asp:ListItem> </asp:DropDownList> <asp:ObjectDataSource ID="ZonesDataSource" runat="server" DataObjectTypeName="Keith.ProjectManager.BO.Zones" DeleteMethod="Delete" InsertMethod="Save" SelectMethod="GetList" TypeName="Keith.ProjectManager.Bll.ZonesManager" UpdateMethod="Update"> <SelectParameters> <asp:Parameter Name="id" /> </SelectParameters> </asp:ObjectDataSource> </p> </div> </form>
thanks
Shem



LinkBack URL
About LinkBacks

Reply With Quote

no luck 

Bookmarks