@Prog! - ASP.NET -
ASP.NET(C#) - AJAX, Silverlight - のメモ書き

GridView のデータソースをLINQ to SQL でセットする

Latest post 10-26-2008 22:17 by Yu Asano. 1 replies.
  • 10-26-2008 22:17

    • Yu Asano
    • Top 10 Contributor
    • Joined on 10-22-2008
    • Japan
    • Posts 208
    • Points 0

    GridView のデータソースをLINQ to SQL でセットする

    using System;
    using System.Linq;
    using System.Web.Configuration;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (Test1 db = new Test1(WebConfigurationManager.ConnectionStrings["Test1ConnectionString"].ConnectionString))
            {
                GridView1.DataSource = from t in db.Table_1 select t;
                GridView1.DataBind();
            }
        }
    }

    • Post Points: 0
  • 10-26-2008 22:17 In reply to

    • Yu Asano
    • Top 10 Contributor
    • Joined on 10-22-2008
    • Japan
    • Posts 208
    • Points 0

    Re: GridView のデータソースをLINQ to SQL でセットする

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>ScriptManager SetFocus</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="GridView1" runat="server">
                    </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>

    Filed under:
    • Post Points: 0
Page 1 of 1 (2 items) | RSS
momotchi.net
Powered by Community Server (Non-Commercial Edition), by Telligent Systems