[Original] DataGrid page, sorting (positive order) function and attention

xiaoxiao2021-03-06  41

asp: BoundColumn DataField = "C_NAME" SortExpression = "C_NAME" HeaderText = "subjects name"> dropdownlist Code Tokyo Kyushu Hokkaido Four countries aspx.cs file code core as follows: protected static string sortexp ; // Sort by private void page_load (object sender, system.eventargs e) {if (! "=" 0 "; sortexp =" "; // initialization DDLWK_GETS (); bindgrid () ; // dategrid Get data and bind data source}} private void DDLWK_GETS () {Switch (sessio n ["wp"]. TOSTRING ()) {CASE "0": ddlwk.selectedIndIndex = 0; Break; Case "3": ddlwk.selectedIndex = 1; Break; Case "8": ddlwk.selectedIndex = 2; BREAK Case "9": ddlwk.selectedIndex = 3; Break; default: ddlwk.selectedIndIndex = 0; Break;}} protected void bindgrid () {dataView DV = getData (). Tables ["VCO"

] .DefaultView; if (sortexp! = ") DV.Sort = sortexp; // give data source plus myDataGrid.dataSource = DV; mydatagrid.database (); //count.text=mydatagrid.columns.count.toString ();

///

/// Returns Data /// /// private dataset getdata () {string strConn = (String) context.getconfig ("System System .web / database ")) [" strConn "]; using (SqlConnection conn = new SqlConnection (strConn)) {SqlCommand cmd = new SqlCommand (" sp_C ", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters. Add ("@ Place", SqldbType.varchar, 2); cmd.Parameters ["@ Place"]. Value = session ["wp"]. TOSTRING (); conn.open ();

Sqldataadapter Da = new sqldataadapter (); da.selectcommand = cmd; dataset ds = new dataset (); da.fill (ds, "vco"); count.text = "ヒ ヒ ト:" DS.Tables ["vco"] .Rows.count.toString () "pieces"; return ds;}

} ///

/// From DataSet 1 /// protected void MyDataGrid_Delete (Object sender, DataGridCommandEventArgs E) {String strID = MyDataGrid.DataKeys [(int) E.Item.ItemIndex] .ToString (); // delete} /// /// paging operations /// /// /// protected void MyDataGrid_PageIndexChanged (object source, DataGridPageChangedEventArgs e) {myDataGrid. CurrentPageIndex = E.NewpageIndex; bindgrid ();} /// /// sort /// /// protected void Sort_Grid (object sender, DataGridSortCommandEventArgs e) {if (SortExp == e.SortExpression) SortExp = "DESC"; else SortExp = e.SortExpression; BindGrid ();} #region Web override Protected void Oninit (Eventargs E) {/// InitializeComponent (); base.onit (e);} /// /// private vidinitia LizeComponent () {this.ddlwk.selected IndexChanged = new system.eventhandler (this.ddlwk_selected "; this.load = new system.eventhandler (this.page_load);

} #Endregion

转载请注明原文地址:https://www.9cbs.com/read-61959.html

New Post(0)