我想遍历Telerik RadGrid的所有列并将值存储在SQL DataBase中。我尝试过这种方法,但我得到的价值是“& nbsp”。 任何小帮助将不胜感激,因为我是asp.net的新手
for (int i = 0; i < this.RadGridDetails.Items.Count; i++)
{
new SqlCommand("insert into tbl1(col1,col2,col3,col4) " +
"values('" + this.RadGridDetails.Items[i].Cells[0].Text.Trim().ToString() + "','" + this.RadGridDetails.Items[i].Cells[1].Text + "',case when '" + this.RadGridDetails.Items[i].Cells[2].Text + "' = 'Block' then 0 else 1 end " +
",'" + this.t1.SelectedValue.ToString() + "' ) ", con).ExecuteNonQuery();
}
答案 0 :(得分:0)
TRY:
foreach (GridDataItem item in RadGridDetails.MasterTableView.Items)
{
new SqlCommand("insert into tbl1(col1,col2,col3,col4) " +
"values('" + item[ColumnUniqueName1].Text + "','" + item[ColumnUniqueName2].Text + "',case when '" + item[ColumnUniqueName3].Text + "' = 'Block' then 0 else 1 end " +
",'" + this.t1.SelectedValue.ToString() + "' ) ", con).ExecuteNonQuery();
}
当然在每列中声明其UniqueName