As you said, "from the same data sources as the drop-down lists, I get a smaller separate list in the drop-down list."
You can save Database Information
to ViewState . This way you can prevent Request to Database
for your client request. Thus, Reducing the Access time
.
Example
public DataTable Employees { get { if (ViewState["Employees"] == null) { return FollowsDAL.GetAllEmployees(); } return (DataTable)ViewState["Employees"]; } set { ViewState["Employees"] = value; } }
How to quickly filter ViewState
data?
The answer is do not use the Update Panel
. I will use the Page Method
.
Please see the example below. I used Update Panel
with Script Manager
.
Exit
To display a 22 character string, you can check how much data is received and sent to the server. Imagine the following
- If you want to send each request to the database using the update panel, and your GridView is in the
Update Panel
!!!!!! - If you use ViewState data for each request and
GridView
inside Update Panel
.
Both of the above methods are the worst in my understanding.
Now I will describe you Page Methods
Method Page Above Update Panel
Page methods
enable ASP.NET AJAX
pages to directly execute Page's Static Methods
using JSON (JavaScript Object Notation)
. Instead of posting back and then receiving HTML markup
to completely replace our UpdatePanel's contents
we can use the web method
to request only the information of interest.
Code example
Exit
So, the conclusion is that I will definitely use ViewState
BUT with Page methods
.
Filter method for ViewState data.
public static class GetFilteredData { public static DataTable FilterDataTable(this DataTable Dt, string FilterExpression) { using (DataView Dv = new DataView(Dt)) { Dv.RowFilter = FilterExpression; return Dv.ToTable(); } } }
Example
DataTableObject.FilterDataTable("Search Expression")
Hi vpiTriumph ... I found a bit of improvement in the code. The proposed approach is presented below.
Sample code in C Sharp
private void DsataBaseInteraction() { using (SqlConnection con = new SqlConnection("Your Connection String")) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "Your Stored Procedure name"; using (SqlDataReader DR = cmd.ExecuteReader()) { } } } }
@KevinDeus - I assume that Database
SQL Server
. Below is my suggestion for the Stored Procedure
in Database
.
Create Proc ProcedureName @UserName Varchar(50), @Password Varchar(50), @Email Varchar(50) As SET NOCOUNT ON SET XACT_ABORT ON Begin Try Begin Tran Insert into Account (Username,Password, Email) Values(@UserName, @Password, @Email) Commit Tran End Try Begin Catch Rollback Tran End Catch