求教Jquery的Ajax事件

我选择下拉框列的时候无刷新的绑定GridView。值传过去了,也跳进了相应的方法,值也绑定上去了,可是页面上GridView还是没有值。是没有刷新的原因吗?有人能帮我解决下吗?

脚本代码:

$("#drpRegion").change(function(){                           
                    var id=$("#drpRegion").val();                   
                    if(id!=0)
                    {
                        $("#lbregion").html("");
                        $.ajax({
                            type:"POST",
                            url:"addrecordplan.aspx?regionid="+id,
                            datatype:"html",
                            success:function(data)
                            {
                               
                            }
                        })
                    }
               });

前台代码:

<tr>
                                            <td align="left" width="100">
                                                区域:
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="drpRegion" runat="server" AutoPostBack="false"
                                                    onselectedindexchanged="drpRegion_SelectedIndexChanged1">
                                                </asp:DropDownList>
                                                <asp:Label ID="lbregion" runat="server" Text=""></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" width="100">
                                                镜头:
                                            </td>
                                            <td>
                                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" CssClass="gridview_m">
                                                    <Columns>
                                                        <asp:BoundField DataField="name" HeaderText="设备名称" />
                                                        <asp:BoundField DataField="regionname" HeaderText="区域名称" />
                                                    </Columns>
                                                </asp:GridView>
                                            </td>                                          
                                        </tr> 

后台代码:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {                                     
                if (Request.QueryString["regionid"] != null)
                {
                    Bind(Request.QueryString["regionid"]);
                }            
            else
            {
                Page.RegisterStartupScript("", "<script>top.location.href='../Login.aspx'</script>");
            }                  
        }       
    }

 

///绑定GridView 的方法

 void Bind(string regionid)
    {     
        DeviceSystem devicesys = new DeviceSystem();
        string message;
        List<Device> devicelist = devicesys.GetDeviceList(u.sessionid, u.nasid.ToString(), out message);
        List<Device> devices = new List<Device>();
        foreach (Device item in devicelist)
        {
            if (item.regionid.ToString() == regionid)
            {
                devices.Add(item);
            }
        }
        GridView1.DataSource = devices;
        GridView1.DataBind();       
    }

 

posted on 2010-10-15 15:41  hbgdluck  阅读(545)  评论(8编辑  收藏  举报

导航