-1
我在表单中有一个Radgrid和RadCombobox。在一个函数中,我打电话给一个forloop。在那forloop我使用Rebind事件的网格。在循环中,第一次从Needdatasource事件发生后的第二次NeedDataSource事件发生,RadGrid - 重新绑定
当Combobox文本更改时,网格应该去NeedDataSource事件。 Plz的帮助。
for (int a = 0; a < EmpCodecmb.Items.Count; a++)
{
EmpCodecmb.Text = EmpCodecmb.Items[a].Text;
EmpCodecmb.SelectedValue = EmpCodecmb.Items[a].Value;
SqlCommand cmd1 = new SqlCommand();
con.Open();
cmd1.Connection = con;
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Clear();
cmd1.CommandText = "get_EmpLeaveDetails";
cmd1.Parameters.AddWithValue("@EmployeeID", EmpCodecmb.SelectedValue);
cmd1.Parameters.AddWithValue("@SelectedMonth", commonDatetime);
SqlDataReader sdp1 = cmd1.ExecuteReader();
while (sdp1.Read())
{
CLtxt.Text = sdp1["CL"].ToString();
ELtxt.Text = sdp1["EL"].ToString();
LOPtxt.Text = sdp1["LOP"].ToString();
}
con.Close();
Grid1.Rebind();
Grid2.Rebind();
Insert_f1();
Insert_f2();
}`
使用重新绑定方法在for循环中不是一个好方法,你应该让你的代码更高效。 – yogi 2012-08-01 09:27:30
任何想法,PLZ ?? – SuganR 2012-08-01 09:28:38
如果你可以在For循环之前创建一个DataTable并使用DataTable..Rows.Add()添加行,然后执行Bind – 2012-08-01 09:36:03