Populate a gridview from a stored proc

HawaiiDragon
HawaiiDragon used Ask the Experts™
on
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!!!
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();


        }

Open in new window

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

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Paul JacksonSoftware Engineer
Top Expert 2011
Commented:
Please post your gridview code from the aspx page.
Commented:
Try removing the datasourceid in the properties window.

Author

Commented:
@jacko72

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
    EnableModelValidation="True">
</asp:GridView>

Author

Commented:
ha ha hah I removed the Datasource ID and got rid of the problem eveyone gets free points!!!!

I feel retarded LOL

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial