السلام عليكم ورحمة الله وبركاته،
لي يومين آحاول حل هذي المشكلة
Error Message: DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'pID'.
وآتمنى مساعدتكم مشكورين في الكود
index.aspx
<tr>
<td style="WIDTH: 146px; HEIGHT: 19px"> <asp:label id="lblAreaNew" runat="server" CssClass="BoldBlueLabel">Area:</asp:label>
<asp:label id="Label157" runat="server" CssClass="BoldRedLabel" Visible="False">*</asp:label></td>
<td style="HEIGHT: 19px"><asp:dropdownlist id="lstAreaNew" runat="server" CssClass="BoldBlueLabel" DataValueField="aID" DataTextField="aDescription" AutoPostBack="True"></asp:dropdownlist></td>
</tr>
<tr id="trAreaLocation" runat="server">
<td style="WIDTH: 146px; HEIGHT: 19px"> <asp:label id="lblPoleNoNewByPost" runat="server" CssClass="BoldBlueLabel">Post No:</asp:label>
<asp:label id="Label30" runat="server" CssClass="BoldRedLabel" Visible="False">*</asp:label></td>
<td style="HEIGHT: 19px">
<asp:dropdownlist id="lstPoleNoNewByPost" runat="server" CssClass="BoldBlueLabel" DataValueField="pLocation" DataTextField="pID"
AutoPostBack="True"></asp:dropdownlist>
<%--<asp:label id="lblLocationNewByPost" runat="server" CssClass="BoldBlueLabel">Location\Street:</asp:label><asp:label id="Label31" runat="server" CssClass="BoldBlueLabel"><%=Location%></asp:label>--%>
<asp:label id="lblLocationNewByPost" runat="server" CssClass="BoldBlueLabel">Location\Street:</asp:label>
<asp:dropdownlist id="lstLocationNewByPost" runat="server"
CssClass="BoldBlueLabel" DataValueField="lID"
DataTextField="lDescription" AutoPostBack="True" Enabled="False"></asp:dropdownlist>
</td>
</tr>index.aspx.vb
Sub BindPost()
lstPoleNoNewByPost.DataSource = objOrgs.sp_slbrs_GetPostByAreas(lstAreaNew.SelectedValue)
lstPoleNoNewByPost.DataBind()
Response.Write(lstAreaNew.SelectedValue)
BindLocationByPost()
End SubOrgDB.vb
Public Function sp_slbrs_GetPostByAreas(ByVal intAreaID As Integer) As SqlDataReader
' Create Instance of Connection and Command Object
Dim myConnection As New SqlConnection(GetDBConnectionString())
' Generate Command Object based on Method
Dim myCommand As SqlCommand = SqlCommandGenerator.GenerateCommand(myConnection, _
CType(MethodBase.GetCurrentMethod(), MethodInfo), _
New Object() {intAreaID})
' Execute the command
myConnection.Open()
Dim result As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
' Return the datareader
Return result
End FunctionStored Procedure
USE [DbpPWR03]
GO
/****** Object: StoredProcedure [dbo].[sp_slbrs_GetPostByAreas] Script Date: 12/18/2011 15:15:30 ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[sp_slbrs_GetPostByAreas]
-- Add the parameters for the stored procedure here
@intAreaID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT @intAreaID
SELECT slbrs_tlkpPoles.pID
FROM slbrs_tlkpArea CROSS JOIN
slbrs_tlkpLocations CROSS JOIN
slbrs_tlkpPoles
WHERE (slbrs_tlkpArea.aID = @intAreaID) AND (slbrs_tlkpLocations.lArea = slbrs_tlkpArea.aID)
AND (slbrs_tlkpPoles.pLocation = slbrs_tlkpLocations.lID)
END