使用标头过滤器时SelectedIndexChanged DataBind错误

时间:2018-04-24 09:33:01

标签: asp.net gridview webforms dropdown

我正在尝试使用标题下拉列表中的值过滤我的GridView。 但是我收到此错误消息:“ DataBinding:'System.Data.DataRowView'不包含名称为'[ AnotherColumnThatIsNotSTATUS ]'

的属性

[AnotherColumnThatIsNotSTATUS] =出于某种原因的另一列而不是状态

有人能看到我遗失的东西吗?

var newStudents = [];
var student;
        var students = [
          {name:'Odelia',
           track:'Accounting',
           achievements:'26',
           points: '2260'
          },
          {name:'Jody',
           track:'Web Design',
           achievements:'12',
           points: '890'
          },
          {name:'Yann',
           track:'Javascript',
           achievements:'10',
           points: '2266'
          },
          {name:'Max',
           track:'Marketing',
           achievements:'13',
           points: '1010'
          },
          {name:'Jody',
           track:'iOS',
           achievements:'9',
           points: '1002'
          },
        ]
          for(var i=0;i<students.length;i++){
          student = students[i];
          if(student.name === 'Jody'){
            newStudents.push(student);
          }
        }
    console.log(newStudents[0].name);

2 个答案:

答案 0 :(得分:1)

这对我有用。希望这有帮助..

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    SqlCommand cmd = new SqlCommand();
    cmd.CommandText = "Select [text] from main where status='"+DropDownList1.SelectedValue.ToString()+"'";
    SqlConnection con = new SqlConnection();
    con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    cmd.Connection = con;
    con.Open();
    cmd.ExecuteNonQuery();
    using (SqlDataAdapter da = new SqlDataAdapter())
    {
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        da.Fill(ds, "Status");
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }

}

答案 1 :(得分:0)

您是否为Gridview指定了列?