Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is doable but not via the visual drag / drop tool. You have to do three things:</p> <ol> <li><p>Create a new method from the datacontext class that will be called to "get" your data</p> <pre><code>public partial class DatabaseDataContext { [Function(Name = "dbo.Contact_Get")] [ResultType(typeof(Contact))] [ResultType(typeof(int))] public IMultipleResults GetContacts([Parameter(Name = "PageIndex", DbType = "Int")] System.Nullable&lt;int&gt; pageIndex, [Parameter(Name = "PageSize", DbType = "Int")] System.Nullable&lt;int&gt; pageSize, [Parameter(Name = "Sort", DbType = "NVarChar(10)")] string sort, [Parameter(Name = "ContactTypeId", DbType = "Int")] System.Nullable&lt;int&gt; contactTypeId) { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), pageIndex, pageSize, sort, contactTypeId); return ((IMultipleResults)(result.ReturnValue)); } </code></pre> <p>}</p></li> <li><p>Create a new page template (List.aspx for example) for the particular table you want in the CustomPages folder to control the selecting from.</p></li> <li><p>Control the gridview's selecting mechanism.</p> <pre><code>protected void GridDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e) { DatabaseDataContext db = new DatabaseDataContext(); IMultipleResults results = db.GetContacts(e.Arguments.StartRowIndex, e.Arguments.MaximumRows, e.Arguments.SortExpression, (int?)e.WhereParameters["ContactTypeId"]); e.Result = results.GetResult&lt;Contact&gt;().ToList(); e.Arguments.TotalRowCount = results.GetResult&lt;int&gt;().Single&lt;int&gt;(); </code></pre> <p>}</p></li> </ol> <p>Check out the Dynamic Data SP sample on the codeplex site for DD that shows you how to do this:</p> <p><a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14473" rel="nofollow noreferrer">http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14473</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload