将新输入的记录显示在gridview的第一行上 [英] displaying the newly entered record on to the first row of gridview

查看:124
本文介绍了将新输入的记录显示在gridview的第一行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下保存按钮时,记录被保存到数据库中,因此该数据显示在网格视图中.但是,当此数据显示在网格视图中时,新插入的记录将显示在网格视图的最后一行.我想在gridview的第一行上显示此记录.
请帮助我.

when i press a save button the record is saved into database and accordingly this data is shown in grid view. but when this data is shown in grid view the newly inserted record is displayed on the last row of the gridview. i want to display this record on the first row of gridview.
please help me.

推荐答案

如果您发布代码会有所帮助?但在您要加载数据库的查询中,请根据创建时间或身份"列对其进行排序,以将最新的列在顶部.如果来自不同客户端的多个数据插入同时发生,则此解决方案无法确保插入的数据将是第一个.

*仍然发布用于填充数据集或数据表的代码以及用于将其绑定到gridview的代码,然后我们才能为您提供更相关的解决方案
if you post the code would help? but in your query to load the data base sort it base on creation time or identity column to have the latest one on the top. If there are multiple data inserts at the same times from different clients this solution does not ensure that the data inserted would be the very first one.

*Still post the code you are using to fill your dataset or datatable and the code you use to bind it to the gridview then we can give you a more relevant solution


您需要对记录进行排序在数据库或数据源中(在C#中).

示例:

使用查询
You need sort the records in database or in datasource(in c#).

Example:

Using Query
SELECT * FROM TblEmp ORDER EmpID --It will display the sorted records by EmpID
SELECT * FROM TblEmp ORDER JoiningDate --It will display the sorted records by EmpID



BTW根据您的要求使用ASC/DESC(以升序或降序加载记录).

使用数据源



BTW use ASC/DESC based on your requirement(loading records either in Ascending or Descending).

Using Datasource

DataView dataView = new DataView(dTable);
dataView.Sort = " EmpID DESC";--It will display the sorted records by EmpID
GridView1.DataSource = dataView;
GridView1.DataBind();


Select * from TBL1 ORDER BY CreatedDate


这篇关于将新输入的记录显示在gridview的第一行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆