我有一个数据库有isdeleted字段和数据类型是我想要更改按钮上的位值单击Gridview? [英] I Have A Database Having Isdeleted Field And Datatype Is Bit I Want To Change The Bit Value On Button Click In Gridview ?

查看:149
本文介绍了我有一个数据库有isdeleted字段和数据类型是我想要更改按钮上的位值单击Gridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个拥有Isdeleted字段和数据类型的数据库我希望更改gridview中按钮点击的位值,并且还想从gridview隐藏该行,除非我将Isdeleted字段设置为false?



请帮助

I have a database having Isdeleted field and datatype is bit i want to change the bit value on button click in gridview and also want to hide that row from gridview unless i set that Isdeleted field to false?

pls help

推荐答案

1)首先对gridview的选择数据查询进行修改,只显示那些有记录的记录 IsDeleted = false



1) first of all make modification on your select data query for gridview to display only those records which having IsDeleted = false

select......
.........
Where IsDeleted = 0





2)第二次创建一个web方法,通过点击gridview的按钮点击来调用,并且该Web方法负责更改与Is Delete标志相关的数据库表记录。使用jquery ajax调用调用该Web方法,并在执行ajax调用时,找到您的gridview行并将其css属性设置为 display none 或类似的内容以隐藏该行。





2) second create a web method which will called by clicking on your gridview's button click, and that web method is responsible to change your database table record related to Is Delete flag. call that web method using jquery ajax call, and on sucess of ajax call, find your gridview row and set it's css property to display none or something like that to hide the row.

[System.Web.Services.WebMethod]
public static string SetIsDeleted(string id)
{
    //Write your logic to update database entry with IsDeleted flag to false (0)
}







<script type = "text/javascript">
var id = 1; --write your own logic to get id for which you need to set IsDeleted flag
function ShowCurrentTime() {


.ajax({
type: POST
url: Default.aspx / SetIsDeleted
数据:' {id:' + id + ' }'
contentType: application / json; charset = utf-8
dataType: json
成功:OnSuccess,
失败: function (响应){
alert(响应。 d);
}
});
}
function OnSuccess(响应){
// < span class =code-comment>写入逻辑以不显示网格视图行
}


< / script>
.ajax({ type: "POST", url: "Default.aspx/SetIsDeleted", data: '{id: "'+ id + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function(response) { alert(response.d); } }); } function OnSuccess(response) { //write logic to display none your grid view row } </script>





请查看链接 [ ^ ]检查如何定义和使用aspx页面的web方法。



另请查看Link [ ^ ],该文章正在演示如何从gird视图中删除记录以及数据库,哟你只需要按照所有步骤改变逻辑,而不是删除你需要编写查询的记录,只需设置IsDeleted列值。



please check link[^] to check how to define and consume web method of aspx page.

Also please check this Link[^] too, that article is demonstrating how to delete record from gird view as well as database, you just need to follow all the steps and change logic just like instead of deleting record you need to write your query in such a way to just set IsDeleted column value.


这篇关于我有一个数据库有isdeleted字段和数据类型是我想要更改按钮上的位值单击Gridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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