gridview不对ddl的选定索引更改事件进行绑定 [英] gridview is not binding on selected index change event of ddl

查看:64
本文介绍了gridview不对ddl的选定索引更改事件进行绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我试图在DDL SelectedIndexChanged事件上绑定gridview。

但是网格没有绑定。

查询是完美的工作sql server.No编译错误。

i我正在使用三层代码。



代码如下。

.cs文件 -



<前lang =c#> 受保护 void ddlRange_SelectedIndexChanged( object sender,EventArgs e)
{

BindGrid(ddlRange.SelectedValue。的ToString());



}

受保护 void BindGrid( string 语言)
{
try
{

GridView1.DataSource = objMain.Selectinfo(Convert.ToInt32(Session [ RANGE_ID]的ToString()))。
GridView1.DataBind();

}
catch (例外情况)
{
}
最后
{


}

}



类文件代码 -



  public  DataTable Selectinfo(  int  RANGE_ID)
{
ArrayList lstParam = new System.Collections.ArrayList( );
SqlParameter param;
param = new SqlParameter();
param.ParameterName = @ RANGE_ID;
param.SqlDbType = SqlDbType.Int;
param.Value = RANGE_ID;
lstParam.Add(param);

return new ConnectivityStatusDAL.SQLDAL()。SelectData( SP_SelectIinfo,lstParam, false ));
}





出了什么问题请帮忙。

谢谢

解决方案

检查下拉列表的AutoPostBack属性。触发ddlRange_SelectedIndexChanged事件必定为true。有关详细信息,请查看以下链接。



http://asp-net-example.blogspot.in/2009/03/how-to-use-dropdownlist-autopostback.html [ ^ ]



希望它有用。


hi,
i am trying to bind gridview on DDL SelectedIndexChanged event.
but grid is not bind.
query is perfect working in sql server.No compilation error.
i am using three layer code.

code is as follow.
.cs file--

protected void ddlRange_SelectedIndexChanged(object sender, EventArgs e)
    {

        BindGrid(ddlRange.SelectedValue.ToString());
            


    }

protected void BindGrid(string Language)
   {
       try
       {

           GridView1.DataSource = objMain.Selectinfo(Convert.ToInt32(Session["RANGE_ID"].ToString()));
           GridView1.DataBind();

       }
       catch (Exception ex)
       {
       }
       finally
       {


       }

   }


class file code--

public DataTable Selectinfo(int RANGE_ID)
        {
            ArrayList lstParam = new System.Collections.ArrayList();
            SqlParameter param;
            param = new SqlParameter();
            param.ParameterName = "@RANGE_ID";
            param.SqlDbType = SqlDbType.Int;
            param.Value = RANGE_ID;
            lstParam.Add(param);

            return (new ConnectivityStatusDAL.SQLDAL().SelectData("SP_SelectIinfo", lstParam, false));
        }



whats going wrong please help.
thanks

解决方案

Check the "AutoPostBack" property for your Dropdownlist. It must be true to trigger the ddlRange_SelectedIndexChanged event. For more details check the following link.

http://asp-net-example.blogspot.in/2009/03/how-to-use-dropdownlist-autopostback.html[^]

Hope it useful.


这篇关于gridview不对ddl的选定索引更改事件进行绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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