更新时间:2023-12-06 10:53:40
protected void lnkbtnAddRow_Click(object sender, EventArgs e)
{
if(Session["Data"]==null)
{
DataTable dt = new DataTable();
DataColumn[] columns = { new DataColumn("Country", System.Type.GetType("System.String")), new DataColumn("Language", System.Type.GetType("System.String")), new DataColumn("Description", System.Type.GetType("System.String")) };
dt.Columns.AddRange(columns);
}
else
{
DataTable dt=(DataTable)Session["Data"];
}
DataRow dr;
dr = dt.NewRow();
dr[0] = ddlCountry.SelectedValue;
dr[1] = ddlLanguage.SelectedValue;
dr[2] = txtDescription.Text;
dt.Rows.Add(dr);
Session["Data"]=dt;
GVaddrow.DataSource = dt;
GVaddrow.DataBind();
}
尝试这个...它应该有用...
问候
Dinesh Kumar.V。
Try this...It should work...
Regards
Dinesh Kumar.V.
您好,
请参阅此。
http://www.aspsnippets.com/Articles/Adding-Dynamic-Rows-in-ASP.NET-GridView-Control-with-TextBoxes-and-with-Delete-functionality.aspx [ ^ ]
希望这有帮助
Hi,
Refer this.
http://www.aspsnippets.com/Articles/Adding-Dynamic-Rows-in-ASP.NET-GridView-Control-with-TextBoxes-and-with-Delete-functionality.aspx[^]
Hope this helps