Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging LinqDataSource with Button click
    primarykey
    data
    text
    <p>I have a GridView on my asp page. I want to change the LinqDataSource with a button click. it's because i have 2 database views and you have to be able to see one of these to views as you wish. My problems is nothing happens when I try to bind the GridView to any of my LinqDataSource'.</p> <p>My C# code:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { this.Grid.DataSource = lqds_Grid1; this.Grid.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { if (this.Grid.DataSource == lqds_Grid1) { this.Grid.DataSource = lqds_Grid2; this.Grid.DataBind(); } else { this.Grid.DataSource = lqds_Grid1; this.Grid.DataBind(); } } </code></pre> <p>my asp code:</p> <pre><code>&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AddressReporting._Default" %&gt; &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt; &lt;asp:LinqDataSource ID="lqds_Grid1" runat="server" ContextTypeName="AddressReporting.MobileGateway" EntityTypeName="" OrderBy="AdrID, Country" TableName="BarcodeWithLocation"&gt; &lt;/asp:LinqDataSource&gt; &lt;asp:LinqDataSource ID="lqds_Grid2" runat="server" ContextTypeName="AddressReporting.MobileGateway" EntityTypeName="" OrderBy="AdrID, Country" TableName="BarcodeWithLocationSorted"&gt; &lt;/asp:LinqDataSource&gt; &lt;asp:GridView ID="Grid" runat="server" AllowPaging="True" AutoGenerateColumns="False" Height="217px" Width="268px"&gt; &lt;/asp:GridView&gt; &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /&gt; &lt;/asp:Content&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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