HawaiiDragon
asked on
Populate a gridview from a stored proc
I havent done this one in a while ... .I have a gridview that I need to populate from a stored procedure below is both my code and the stored proc code. I am geting an erro that states:
Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.
help!!!
Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.
help!!!
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(Settings.GetConfigValue("PARK_GradeAppeal_v1", "GradeAppealSuperConnections"));
con.Open();
SqlCommand cmd = new SqlCommand("P_sp_GetAdmin", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader sdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(sdr);
GridView1.DataSource = dt;
GridView1.DataBind();
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE [dbo].[P_sp_GetAdmin]
-- Add the parameters for the stored procedure here
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 * from tbl_AdminUsers
END
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ha ha hah I removed the Datasource ID and got rid of the problem eveyone gets free points!!!!
I feel retarded LOL
I feel retarded LOL
ASKER
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSourc
EnableModelValidation="Tru
</asp:GridView>