Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6187465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:03:47+00:00 2026-05-24T02:03:47+00:00

Like once said a picture worth one thousand word when I press the edit

  • 0

Like once said a picture worth one thousand word
The original data before applying the filter

After applying the filter , Now I'm going to press edit button

when I press the edit button I go back to the old data, with first row in the edit mode
like the following
The Problem

this is the code I use when searching with student name , or date ….

LinqDataSource1.Where = "pay_date.Contains(" + 

(Convert.ToString(Convert.ToDateTime(TextBox1.Text))) + ")";

I tried to use AJAX , didn’t work
I found in the linqdatasource a property called linqdatasource storeoriginalvaluesinviewstate
I made it false but go the same problem ,

.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EDPayment.ascx.cs" Inherits="Admin_ED_EDPayment" %>

    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
        <Services>
        <asp:ServiceReference Path="~/Admin/ED/Student_AutoComplete.asmx" />            
        </Services>        
    </asp:ScriptManagerProxy>
        <br />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
            <div>
            <asp:Label ID="Label3" runat="server" 
    Text="Search By Student Name:"></asp:Label>
            <asp:TextBox runat="server" ID="myTextBox" Width="300" ontextchanged="myTextBox_TextChanged" />
            <asp:autocompleteextender
                runat="server" 
                ID="autoComplete1" 
                TargetControlID="myTextBox"
                ServicePath="~/Admin/ED/Student_AutoComplete.asmx"
                ServiceMethod="GetCompletionList"
                MinimumPrefixLength="1" 
                CompletionInterval="1000"
                EnableCaching="true"
                CompletionSetCount="12" />
                &nbsp;<asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                    Text="Search" />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <br />
<br />
<asp:Label ID="Label4" runat="server" Text="Search By Date:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" 
    BehaviorID="TextBox1_CalendarExtender" Enabled="True" 
    TargetControlID="TextBox1">
</asp:CalendarExtender>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Search" />
    <br />
<br />
<asp:Button ID="Button3" runat="server" onclick="Button3_Click" 
    Text="Search By Date &amp; Name" />
    <br />
<asp:Label ID="Label5" runat="server"></asp:Label>
    <br />
<asp:Button ID="Button4" runat="server" onclick="Button4_Click" 
    Text="Show All Payments" /></div>

        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
    AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="pay_id" 
    DataSourceID="LinqDataSource1" onrowediting="GridView1_RowEditing">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="pay_id" HeaderText="pay_id" InsertVisible="False" 
            ReadOnly="True" SortExpression="pay_id" />
                <asp:BoundField DataField="pay_amount" HeaderText="pay_amount" 
            SortExpression="pay_amount" />
                <asp:BoundField DataField="pay_date" HeaderText="pay_date" 
            SortExpression="pay_date" />
                <asp:TemplateField HeaderText="pay_st_id" SortExpression="pay_st_id">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" 
                    DataSourceID="LinqDataSource2" DataTextField="st_fullname" 
                    DataValueField="st_id" SelectedValue='<%# Bind("pay_st_id") %>'>
                        </asp:DropDownList>
                        <asp:LinqDataSource ID="LinqDataSource2" runat="server" 
                    ContextTypeName="TeacherAssistantDataContext" 
                    OrderBy="st_fname, st_mname, st_lname" Select="new (st_fullname, st_id)" 
                    TableName="students">
                        </asp:LinqDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("pay_st_id") %>' 
                    Visible="False"></asp:Label>
                        <asp:DropDownList ID="DropDownList2" runat="server" 
                    DataSourceID="LinqDataSource3" DataTextField="st_fullname" 
                    DataValueField="st_id" Enabled="False">
                        </asp:DropDownList>
                        <asp:LinqDataSource ID="LinqDataSource3" runat="server" 
                    ContextTypeName="TeacherAssistantDataContext" 
                    OrderBy="st_fname, st_mname, st_lname" Select="new (st_id, st_fullname)" 
                    TableName="students" Where="st_id == @st_id">
                            <WhereParameters>
                                <asp:ControlParameter ControlID="Label1" Name="st_id" PropertyName="Text" 
                            Type="Int32" />
                            </WhereParameters>
                        </asp:LinqDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
            <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                ContextTypeName="TeacherAssistantDataContext" EnableDelete="True" 
                EnableUpdate="True" OrderBy="pay_date, pay_amount, pay_st_id" 
                TableName="payments">
            </asp:LinqDataSource>
    </ContentTemplate>
</asp:UpdatePanel>

.ascx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ED_EDPayment : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        go1();
    }
    protected void go1()
    {       
        int[] id = Searcher._Student.searchByst_fullName2(myTextBox.Text);
        LinqDataSource1.Where = "pay_st_id == " + id[0].ToString();
       // Parameter p = new Parameter("", System.Data.DbType.Int32, id[0].ToString());
        //LinqDataSource1.WhereParameters.Add(p);
       // LinqDataSource1.DataBind();
        //fix();

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        go2();
    }
    protected void go2()
    {
        LinqDataSource1.Where = "pay_date == DateTime.Parse(\"" + TextBox1.Text + "\")";

        fix();
    }
    void fix()
    {
    //    LinqDataSource1.
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        int[] id = Searcher._Student.searchByst_fullName2(myTextBox.Text);
        LinqDataSource1.Where = "pay_st_id == " + id[0].ToString() + " AND " + "pay_date == DateTime.Parse(\"" + TextBox1.Text + "\")";
    }
    protected void myTextBox_TextChanged(object sender, EventArgs e)
    {
        go1();
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        go2();
    }

    protected void Button4_Click(object sender, EventArgs e)
    {
        LinqDataSource1.TableName = "payments";
        LinqDataSource1.DataBind();        
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:03:48+00:00Added an answer on May 24, 2026 at 2:03 am

    I found a solution based on this topic : How can I prevent the LinqDataSource Where clause from resetting on postback? :Source
    All I needed is to save the where clause of the linqdatasource and reload it again in the page_load event the final code become

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Admin_ED_EDPayment : System.Web.UI.UserControl
    {
        //private Boolean b1 = false, b2 = false, b3 = false;
        public string MyLinqSourceWhere
        {
            get { return (string)this.ViewState["MyLinqSourceWhere"]; }
            set { this.ViewState["MyLinqSourceWhere"] = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.LinqDataSource1.Where = this.MyLinqSourceWhere;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            go1();
        }
        protected void go1()
        {       
            int[] id = Searcher._Student.searchByst_fullName2(myTextBox.Text);
            this.MyLinqSourceWhere = "pay_st_id == " + id[0].ToString();
            this.LinqDataSource1.Where = this.MyLinqSourceWhere;
        }
        protected void go3()
        {
            int[] id = Searcher._Student.searchByst_fullName2(myTextBox.Text);
            this.MyLinqSourceWhere = "pay_st_id == " + id[0].ToString() + " AND " + "pay_date == DateTime.Parse(\"" + TextBox1.Text + "\")";
            this.LinqDataSource1.Where = this.MyLinqSourceWhere;
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            go2();        
        }
        protected void go2()
        {
            this.MyLinqSourceWhere = "pay_date == DateTime.Parse(\"" + TextBox1.Text + "\")";
            this.LinqDataSource1.Where = this.MyLinqSourceWhere;
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            go3();
        }
        protected void myTextBox_TextChanged(object sender, EventArgs e)
        {
            go1();
        }
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            go2();
        }
    
        protected void Button4_Click(object sender, EventArgs e)
        {
            LinqDataSource1.TableName = "payments";
            LinqDataSource1.DataBind();        
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

as the title said i would like to create a button that says available
I read a quote from Zed Shaw once that said something like if a
I am flying blind on scheme, and I feel like once I answer this
hi I am trying to get user profile information like this once the authentication
I have created a php/mysql based chat page.It is like gmail chat.once i click
I'm having a simple test design problem, which I would like to solve once
I'm writing a physics simulating program, and found after() useful. I once would like
I would like for the pop up to appear once the page loads, without
Once again my silliness has struck. I would like to thank everyone who helped
I'd like to load a font from an external server and once is loaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.