我的aspx页面上有一个gridview控件,我在其中插入数据并且工作正常但是现在我想在每行之间添加一个下拉列表例如: 假设这是我的插入行:
Name Age Country
现在插入此行后,我想要自动添加一行,只有一个下拉列表,没有别的......这可能吗?任何人都可以帮忙吗?
这是我在GridView中添加Rows的代码
DataTable dt_amount = new DataTable();
if (validateAmountLevelAdding())
{
dt_amount.Columns.Add("Sr.No");
dt_amount.Columns.Add("User");
dt_amount.Columns.Add("Min_Amount");
dt_amount.Columns.Add("Max_Amount");
dt_amount.Columns.Add("Level");
dt_amount.Columns.Add("emp_code");
dt_amount.Columns.Add("job_id");
int NextSerail = 0;
foreach (GridViewRow gvRow2 in GV_AMOUNT_EMP.Rows)
{
dt_amount.Rows.Add();
dt_amount.Rows[dt_amount.Rows.Count - 1][0] = gvRow2.Cells[0].Text;//serial no
dt_amount.Rows[dt_amount.Rows.Count - 1][1] = gvRow2.Cells[1].Text;//User
dt_amount.Rows[dt_amount.Rows.Count - 1][2] = gvRow2.Cells[2].Text;//Minimum Amount
dt_amount.Rows[dt_amount.Rows.Count - 1][3] = gvRow2.Cells[3].Text;//Maximum Amount
dt_amount.Rows[dt_amount.Rows.Count - 1][4] = gvRow2.Cells[4].Text;//level
dt_amount.Rows[dt_amount.Rows.Count - 1][5] = gvRow2.Cells[5].Text;//empCode
dt_amount.Rows[dt_amount.Rows.Count - 1][6] = gvRow2.Cells[6].Text;//JobId
NextSerail = Convert.ToInt32(gvRow2.Cells[0].Text)+1;
}
if(NextSerail==0)
{
NextSerail = 1;
}
dt_amount.Rows.Add();
dt_amount.Rows[dt_amount.Rows.Count - 1][0] = NextSerail;
dt_amount.Rows[dt_amount.Rows.Count - 1][1] = DDL_EmpForAmount.SelectedItem;
dt_amount.Rows[dt_amount.Rows.Count - 1][2] = txt_min_amount.Text.ToString();
dt_amount.Rows[dt_amount.Rows.Count - 1][3] = txt_max_amount.Text.ToString();
dt_amount.Rows[dt_amount.Rows.Count - 1][4] = DDL_LEVELS_AMOUNT.SelectedValue;
dt_amount.Rows[dt_amount.Rows.Count - 1][5] = DDL_EmpForAmount.SelectedValue;
dt_amount.Rows[dt_amount.Rows.Count - 1][6] = DDL_Jobs.SelectedValue;
Session["levels_amount"] = dt_amount;
GV_AMOUNT_EMP.DataSource = Session["levels_amount"] as DataTable;
GV_AMOUNT_EMP.DataBind();
}