USE [JxtMsg]
GO
/****** 对象:  StoredProcedure [dbo].[Pad_SearchMessage]    脚本日期: 04/22/2008 15:25:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:
-- Create date: 2008-04-10
-- Description: 查询手机接收消息
-- =============================================
ALTER PROCEDURE [dbo].[Pad_SearchMessage] 
@mobile varchar(12),
@path varchar(50),
@Ret int output
AS
set @Ret=1
BEGIN
if (@path='72' or @path='35' or @path='22' or @path='25' or @path='41' or @path='42')
       begin
         
         select fdestaddr,FUD,FDeliverTime,fstatus from [172.16.1.213].newcoverm.dbo.billingtable where fdestaddr=@mobile order by fdestaddr desc
         if @@error=0
 begin
 set @Ret=0
 return
end
       end 
   else 
      if (@path='31' or @path='34')
begin
select fdestaddr,FUD,FDeliverTime,fstatus from [172.16.1.217].newcoverm.dbo.billingtable where fdestaddr=@mobile order by fdestaddr desc
                if @@error=0
begin
 set @Ret=0
 return
end
                
end
  else
        select mobile,Msgcontent,submittime,path from   jxtsms.dbo.Sms_WaitSendLog where mobile=@mobile   order by submittime desc 
          if @@error=0
  begin
  set @Ret=0
  return  
  end
END
<asp:GridView ID="GrvMsg" runat="server" CellPadding="4" GridLines="None" Width="100%" AutoGenerateColumns="False" ForeColor="#333333">
              <FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True" />
              <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
              <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
              <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
              <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
              <AlternatingRowStyle BackColor="White" />
              <Columns>
                <asp:BoundField DataField="fdestaddr" HeaderText="手机号码">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="FUD" HeaderText="消息">
                    <ItemStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="FdeliverTime" HeaderText="手机接收时间">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="Fstatus" HeaderText="状态">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
            </Columns>
          </asp:GridView>
                       &nbsp;
                       
                       <asp:GridView ID="GridView2" runat="server"  AutoGenerateColumns="False" Width="100%" CellPadding="4" GridLines="None" ForeColor="#333333">
        <Columns>
                <asp:BoundField DataField="mobile" HeaderText="手机号码">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                <asp:BoundField DataField="Msgcontent" HeaderText="消息">
                    <ItemStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="submittime" HeaderText="提交时间">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:BoundField>
                 </Columns>
            <FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>我有一个button按钮,我想通过点击这个按钮调用这个存储过程,问题是我不知道该怎么判断到底绑定哪个gridview
protected void BtnSearchMsg_Click(object sender, EventArgs e)
    {
       Jxllt.DBUtility.DbHelperSQL.ConnDataBase("jxtmsg", "");
        SqlParameter[] plist ={
                                     new SqlParameter(strMobile,SqlDbType.VarChar,12),
                                     new SqlParameter(strPath,SqlDbType.VarChar,50),
                                     new SqlParameter(ret,SqlDbType.Int)
                                  };
        plist[0].Value = this.TxtMobile.Text.Trim().ToString();
        plist[1].Value = this.HidPath.Value.ToString();
        plist[2].Direction = ParameterDirection.Output;
        ds = Jxllt.DBUtility.DbHelperSQL.RunProcedure("Pad_SearchMessage", plist, "tmobilepath");
        this.GrvMsg.DataSource = ds;
        this.GrvMsg.DataBind();}当我执行的时候会经常出现找不到fdestaddr或者是mobile 字段,我知道这里面需要一个条件来判断该绑定哪个gridview 但是我不知道这个判断应该怎么写,有没有人帮忙指点下

解决方案 »

  1.   

            this.GrvMsg.DataSource = ds; 
            this.GrvMsg.DataBind(); 是不是这里的绑定
      

  2.   

    我如果输入另外一张表的数据话就就会出现fdestaddr字段的问题 
    如果就输入这张表的数据话就又会出现找不mobile 字段的问题
    我想通过一个判断语句来绑定不同的gridview
      

  3.   

     if (this.HidPath.Value == "31" || this.HidPath.Value == "72" || this.HidPath.Value == "35" || 
    protected void BtnSearchMsg_Click(object sender, EventArgs e) 
        { 
           Jxllt.DBUtility.DbHelperSQL.ConnDataBase("jxtmsg", ""); 
            SqlParameter[] plist ={ 
                                         new SqlParameter(strMobile,SqlDbType.VarChar,12), 
                                         new SqlParameter(strPath,SqlDbType.VarChar,50), 
                                         new SqlParameter(ret,SqlDbType.Int) 
                                      }; 
            plist[0].Value = this.TxtMobile.Text.Trim().ToString(); 
            plist[1].Value = this.HidPath.Value.ToString(); 
            plist[2].Direction = ParameterDirection.Output; 
            ds = Jxllt.DBUtility.DbHelperSQL.RunProcedure("Pad_SearchMessage", plist, "tmobilepath"); 
      if (this.HidPath.Value == "31" || this.HidPath.Value == "72" || this.HidPath.Value == "35" || this.HidPath.Value == "22" || this.HidPath.Value == "25" || this.HidPath.Value == "41" || this.HidPath.Value == "42" || this.HidPath.Value == "34")
            {
                this.GridView2.Visible = false;
                this.LblMessage.Text = "消息内容:";
                this.GrvMsg.DataSource = ds;
                this.GrvMsg.DataBind();
             
            }
            else
            {
                this.GrvMsg.Visible = false;
                this.LblMessage.Text = "消息内容:";
                this.GridView2.DataSource = ds;
                this.GridView2.DataBind();
            }
         这样就可以了.