In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to query in the ASP.NET Web development framework, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Enterprise Solution supports user-defined queries (query and lookup) and defines query query as a standard function to find the value that lookup uses to return the query to the data entry form.
First configure the database connection string and use company registration to register a new database connection. Then in the query designer, select the corresponding object and design the association, and the Web framework can parse the query and become a page function.
On the customer page, add TriggerBox, which will be followed by a small icon to look up the data
Let's take a look at the processing mode of the background code.
String lookup = tbxCustomerNo.Lookup; tbxCustomerNo.OnClientTriggerClick = Window1.GetSaveStateReference (tbxCustomerNo.ClientID, HiddenField1.ClientID, HiddenField2.ClientID) + Window1.GetShowReference (string.Format ("lookup.aspx?id= {0}", lookup), "Look-up:Customer")
From the Web page above, we have specified the Lookup attribute as CustomerEntryLookup. This sentence associates Lookup with the Window1 of the page for the pop-up window, and specifies that the HiddenField1 of the page is the return value of accepting Lookup. * call the postback refresh process of the window to refresh the page. The code is as follows
Protected void Window1_Close (object sender, EventArgs e) {string customerNo = tbxCustomerNo.Text; if (! string.IsNullOrWhiteSpace (customerNo)) {ReloadEntity (customerNo);}}
This completes the pop-up selection value of the query page, returns the value to the main form, and * refreshes the main form.
Let's take a look at how the lookup.aspx page is designed, which takes a query id as a parameter, which is the CustomerEntryLookup we specified, which is designed like this in the query designer.
The lookup.aspx page accepts the parameters passed in, and its pilot page is designed like this
Protected void Page_Init (object sender, EventArgs e) {LookupName = Request.QueryString ["id"]; ILookupDialogManager _ lookupDialogManager = ClientProxyFactory.CreateProxyInstance (); string companycode = "TS"; DataTable table = _ lookupDialogManager.GetLookupDialogData (LookupName, null, null, 0,0, companycode); Grid1.RecordCount = table.Rows.Count; BindGrid () }
According to the query, get the total number of records, paging query, the code here is the paging code of Grid, to see the definition of the BindGrid method, it is not complicated.
Private void BindGrid () {DataSet ds = LoadData (Grid1.PageIndex+1); while (Grid1.Columns.Count > 0) Grid1.Columns.RemoveAt (0); foreach (DataColumn colu in ds.Tables [0] .Columns) {ExtAspNet.BoundField field = new ExtAspNet.BoundField (); field.ColumnID = colu.ColumnName Field.DataField = colu.ColumnName; field.HeaderText = GetTranslation (colu.ColumnName); Grid1.Columns.Add (field);} Grid1.PageSize = PageSize; Grid1.DataSource = ds.Tables [0]; Grid1.DataBind ();}
It first deletes the existing columns in the grid, then generates new columns based on the results, and applies multilingual translation to the column names. Here, pay attention to the timing of the creation of dynamic controls, choosing to be in Page_Init, not Page_Load. In Debug, the paging code you see is database paging, which returns only the set number of rows at a time.
The sample code for Grid's paging event is shown below, exactly the same as GridView
Protected void Grid1_PageIndexChange (object sender, ExtAspNet.GridPageEventArgs e) {Grid1.PageIndex = e.NewPageIndex; BindGrid ();}
Let's take a look at the code for the two button methods on the lookup.aspx page. The simplest is Close, which closes the form directly and returns no value to the main form. Its code is easiest, as shown below
BtnClose.OnClientClick = ActiveWindow.GetHideReference ()
If it is a little more complicated, close it and bring the value to the main form, as shown in the following code
Protected void btnSaveClose_Click (object sender, EventArgs e) {int rowIndex = Grid1.SelectedRowIndex; GridRow row = Grid1.Rows [rowIndex]; ILookupDialogManager lookupManager=ClientProxyFactory.CreateProxyInstance (); LookupDialogEntity lookup = lookupManager.GetLookupDialog (LookupName); List keyFields = new List (); keyFields.Add (lookup.KeyField1); keyFields.Add (lookup.KeyField2) KeyFields.Add (lookup.KeyField3); List values = new List (); foreach (string keyField in keyFields) {string value = string.Empty; if (! string.IsNullOrWhiteSpace (keyField)) {ExtAspNet.BoundField field = (ExtAspNet.BoundField) Grid1.FindColumn (keyField) String F1 = field.DataField; object f2 = grid1.Rows [rowIndex] .States [field.ColumnIndex]; value = Convert.ToString (DataRowView) (grid1.Rows [rowIndex] .DataItem)) [keyField]);} values.Add (value) } PageContext.RegisterStartupScript (ActiveWindow.GetWriteBackValueReference (values [0], values [1], values [2]) + ActiveWindow.GetHidePostBackReference ();}
This part of the code, there are two purposes, take the value in Grid, and then return to the main form, because you want to refresh the main form, so add a GetHidePostBackReference (), let the main form post back, to call the Window1_Close,ReloadEntity designed at the beginning of the article to complete the rebinding of the entity.
Querying query is implemented on the same principle as finding lookup, both for custom lookup data. Query is used for relatively independent functions and is executable, while lookup is used for finding and returning field values to facilitate form data input. In query designer, you can not only design queries with objects, but also enter SQL statements directly or call stored procedures to implement them.
This makes it easy for users to expand the query function of the system without the need for secondary development.
The above content is how to query in the ASP.NET Web development framework. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.