1

I have a problem, into my project i'm trying to get data from my database into GridView, but on the page data not shown... but in VisualStudio designer mode, i can retreive data into gridview... what i'm doing wrong?

here it code in .aspx page

<div id="default">
<%: Html.ValidationSummary() %>
    <fieldset>
        <ol class="actionRefresh">
            <a href="/Admin/UsersInRolesList" target="_self" title="Refresh Users In Roles List">Users In Roles List<b>&nbsp;</b> </a>
        </ol>

        <form runat="server" id="frmUsers">

            <asp:SqlDataSource ID="sdsUsers" runat="server" 
                ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" 
                SelectCommand="UserProfiles_s_sp" SelectCommandType="StoredProcedure" DataSourceMode="DataReader" ViewStateMode="Disabled">
                <SelectParameters>
                    <asp:Parameter Name="UserProfileID" Type="Int32" />
                    <asp:Parameter Name="UserId" Type="String" />
                    <asp:Parameter Name="UserName" Type="String" />
                    <asp:Parameter Name="PageSize" Type="Int32" />a
                    <asp:Parameter Name="PageNum" Type="Int32" />
                    <asp:Parameter Name="Sort" Type="String" />
                    <asp:Parameter Name="FirstName" Type="String" />
                    <asp:Parameter Name="Additional" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>

            <asp:GridView ID="gvUsers" runat="server" DataSourceID="sdsUsers" AutoGenerateColumns="true" ViewStateMode="Disabled">
                    <EmptyDataTemplate>
                        No data found.
                    </EmptyDataTemplate>
            </asp:GridView>

        </form>

        <div id="divBackTo">
            <a href="<%= Url.Action("Index", "Admin") %>" target="_self" title="Back to Menu"><<
                &nbsp;&nbsp; Back to Menu </a>
        </div>

    </fieldset>
</div>

in controller i have this code:

try
        { }
        catch (Exception ex)
        {
            ModelState.AddModelError(String.Empty, ex.Message);
        }return View();

and when i loaded my page i have "No data found" displayed in gridview...

1 Answer 1

1

The GridView is for ASP.NET WebForms, not ASP.NET MVC. In MVC, the Controller retrieves data as Models and sends them to the View. There is no data access in the View.

See Getting Started with ASP.NET MVC3 for a number of tutorials, including data access.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.