我有一個GridView,我想綁定第一列(教師名)與DropDownList,我有GridView外。我怎樣才能使它工作?如何將GridView的列綁定到DropDownList?
protected void Button2_Click(object sender, EventArgs e)
{
string q = "select * from teacher where teachername='" + drpteachername.SelectedItem.ToString() + "' and ('2013-03-01' between date and todate) and '2013-03-31' between date and todate";
dt = dbo.Getdt(q);
GridView1.DataSource = dt;
GridView1.DataBind();
string teachername=drpteachername.SelectedItem.ToString();
for (int i = 0; i < dt.Rows.Count ;i++)
{
Label lblteachername = (Label)GridView1.Rows[i].Cells[0].FindControl("lblgridteachername");
this.GridView1.Rows[i].Cells[0].Value = teachername;
}
}
*你有什麼*問題? – 2013-03-06 09:07:51
@huMptyduMpty沒有任何反應,我點擊按鈕。上面的代碼既沒有給我任何結果,也沒有任何錯誤。 – Arbaaz 2013-03-06 09:11:48
我收到錯誤 {「索引超出範圍,必須是非負值,小於集合的大小\ r \ n參數名稱:index」} – Arbaaz 2013-03-06 10:48:04