ASP.NET(C#) 开发WebForm,使用GridView的时候遇到两个问题,请帮忙看看:1) protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[0].ToolTip = "显示鼠标信息";
    }
GridView共有五列,但是如果把Cells[0]的参数改为大于0的整数,就会提示错误:“指定的参数已超出有效值的范围。参数名: index”,难道在RowDataBound里面Cells的参数只能是0???2、关于自动分页的问题:
   数据元中这样设置:SelectCommand="select * from a"
   检索代码为:SqlDataSource1.SelectCommand = "select top 11 * from a";
   检索后如果点击页码,那么系统就会自动执行"select * from a",把检索出来的内容给替代了。
   这种情况如何处理啊??请指点一下,谢谢!学习,关注……

解决方案 »

  1.   

    if (e.Row.RowType==DataControlRowType.DataRow)
    {
    e.Row.Cells[0].ToolTip = "显示鼠标信息";
    }
      

  2.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[0].ToolTip = "显示鼠标信息";
                e.Row.Cells[1].ToolTip = "显示鼠标信息";
                e.Row.Cells[2].ToolTip = "显示鼠标信息";
                //..................
            }
        }
      

  3.   

    楼主的说明:谢谢!!第二个问题有人能帮我解答吗??小弟再问一个问题吧,请看下面代码: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Sql" >
    </asp:SqlDataSource>有没有办法传个参数到Sql,而不是一开始就写好Sql语句??关注……
      

  4.   

    2、关于自动分页的问题:
    如果你想每次只显示11条记录可以设置PageSize属性.有没有办法传个参数到Sql,而不是一开始就写好Sql语句??
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:pubsConnectionString %>"
                SelectCommand="SELECT * FROM [authors]" UpdateCommand="update authors set au_lname=@au_lname,phone=@phone,city=@city where au_id=@au_id" DeleteCommand="delete from authors where au_id=@au_id">
                <UpdateParameters>
                    <asp:Parameter Name="au_lname" />
                    <asp:Parameter Name="phone" />
                    <asp:Parameter Name="city" />
                    <asp:Parameter Name="au_id" />
                </UpdateParameters>
                <DeleteParameters>
                    <asp:Parameter Name="au_id" />
                </DeleteParameters>
            </asp:SqlDataSource>