检查GridView记录是否已插入 [英] Check The GridView Records are Inserted or Not

查看:81
本文介绍了检查GridView记录是否已插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 3个GridvViews ,一个是 To ,另一个是 Cc Bcc
将值输入到Grids后,我要保存这些记录.
现在我的问题是---保存时检查数据是否在 3个网格中.

例如:
我从 To 插入记录,但是我没有向 Cc,Bcc 插入记录,然后显示错误输入至少一条记录..." .为此,我编写了Script函数,并使用 OnClientClick 属性调用Script in Save按钮.但是我没有得到,

I have a 3 GridvViews one is To,another one is Cc and Bcc ,
After enter the values to Grids,i want to save those Records.
Now what is my question is ---at the time of saving Check the data is there in 3 Grids or not.

ex:
i insert records from To,but i''m not insert records to Cc,Bcc ,then it shows the "error enter atlest one record..." .I want like this for this i wrote Script function and call the Script in to Save button by using OnClientClick Property.But I''m not getting ,

function Validate() {
            var To = document.getElementById("<%= gvTo.ClientID %>");
            var Cc = document.getElementById("<%= gvCc.ClientID %>");
            var Bcc = document.getElementById("<%= gvBcc.ClientID %>");


            if (To.rows.length < 1 || Cc.rows.length < 1 || Bcc.rows.legth < 1) {
                alert("please enter at least one record");
            }
            else {
                alert("Continue..");
            }
        }



但是我没有完全满足我的要求.请帮助我做到这一点.
这非常紧急...



but i''m not getting my requirement exactly .Plz help me to do this .
This is very urgent...

推荐答案

它不是非常紧急".免费从事工作的人希望提供帮助,但实际上并不在乎您是否无法完成工作.

在我看来,只要您将gridview呈现为表格,它就应该可以工作.我不清楚您为什么需要这样做,请确定您在回发期间是否知道网格的数据源中是否包含任何数据?无论哪种方式,这对我来说都是一团糟,还不清楚但是我没有完全满足我的要求"是什么意思.您是否已浏览Chrome中的js?怎么了 ?
It''s not ''very urgent''. The people doing your job for free want to help, but don''t actually care if you can''t do your job.

This looks to me like it should work, so long as your gridview is rendered as a table. I am unclear why you need to do it this way, surely you know during a postback if your data source for the grid had any data in it ? Either way, this looks messy to me, and it''s unclear what ''but i''m not getting my requirement exactly'' means. Have you stepped through the js in Chrome ? What is happening ? How is it not behaving like you expect ?



试试这个:
Hi,
Try this:
function Validate() {
    var To = document.getElementByID(<%=gvTo.ClientID%>).rows.length;
    var Cc = document.getElementByID(<%=gvCc.ClientID%>).rows.length;
    var Bcc = document.getElementByID(<%=gvBcc.ClientID%>).rows.length;

    if (To < 1 || Cc < 1 || Bcc < 1) {
        alert("please enter at least one record");
    }
    else {
        alert("Continue..");
    }
}



请参考 [



Refer this[^].

--Amit


这篇关于检查GridView记录是否已插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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