ASP GRIDVIEW [英] ASP GRIDVIEW

查看:68
本文介绍了ASP GRIDVIEW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个表格,其中包含姓名,年龄,出生日期,手机号码,座机号码,办公号码,传真.

我想显示用户提供的姓名,年龄,出生日期以及任何来自mobileno,phoneno,officeno,传真号的联系电话.

如果用户未给出手机号码而是给出了电话号码,则该电话号码将在Gridview中显示为cotactno标题.优先级为Landphoneno,mobileno和officeno

在此先感谢!

Hi all,

I have a table contains name, age, dob, mobileno, landphoneno, officeno, fax.

I want to display the name, age, dob and any of the contact Nos from mobileno, phoneno, officeno, fax Nos that was given by the user.

If the user had not given the mobileno but given the phoneno then the phoneno is diplayed in gridview as cotactno heading.The precedency is landphoneno,mobileno and officeno

Thanks in Advance!

推荐答案

有多种方法可以做到这一点,

您只需获取DB中存在的那个数字
其他

从数据库中获取所有列,然后发生一个名为Rowdatabound的事件.在这里,您可以检查存在哪些数据并据此做出决定,我的意思是相应显示或隐藏
There are various ways to do this,

you just fetch only that number that are present in DB
else

fetch all the columns from DB and there is an event called Rowdatabound. In this you can check what data is present and take the decision according, I mean show or hide accordingly


您可以在过程中使用以下代码,获取结果并将其绑定到您的gridview
you can use the following code in a procedure, get the result and bind it to your gridview
select Name,Age, DOB, "Contact No"=
    CASE
        WHEN landphone IS NOT NULL THEN (SELECT landphone from customer cst where cst.CustID = outCust.CustID)
        WHEN mobilephone IS NOT NULL THEN (SELECT mobilephone from customer cst where cst.CustID = outCust.CustID)
        WHEN officeno IS NOT NULL THEN (SELECT officeno from customer cst where cst.CustID = outCust.CustID)
        WHEN fax IS NOT NULL THEN ( SELECT fax from customer cst where cst.CustID = outCust.CustID)
        ELSE 'no contact no'
    END
FROM Customer outCust



我使用了一个类似于您的表定义的表(只是区别是我有一个主键CustID)



I''ve used a table something like your table definition (only the difference is I''ve one Primary Key CustID)


这篇关于ASP GRIDVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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