更新时间:2022-06-04 02:45:51
这里我开发了以下代码
Here I have Developed following code
static DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dt = new DataTable();
dt.Columns.Add("Project Number");
dt.Columns.Add("Title");
dt.Columns.Add("Activity");
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
DataRow dr = dt.NewRow();
dr[0] = DropDownList1.SelectedValue;
dr[1] = DropDownList2.SelectedValue;
dr[2] = DropDownList3.SelectedValue;
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
}
我希望这会对你有所帮助
I hope this will be helpful to you
尝试级联下拉菜单 -
http://www.asp.net/ajaxLibrary /AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx [ ^ ]
http://www.asp.net/ ajaxLibrary / AjaxControlToolkitSampleSite / Walkthrough / CCDWithDB.aspx [ ^ ]
http://code.msdn.microsoft.com/CSASPNETCascadingDropDownLi -0 a3f1ecf [ ^ ]
Try cascading dropdowns -
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx[^]
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Walkthrough/CCDWithDB.aspx[^]
http://code.msdn.microsoft.com/CSASPNETCascadingDropDownLi-0a3f1ecf[^]
请按照以下示例:
Follow this example:
Protected Sub btnSaveEmail_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSaveEmail.Click
dt_email = Session("dt_email") 'OR Dim dt_email As New DataTable
Dim dr As DataRow
dr = dt_email.NewRow()
dr("intCodigoClienteEmail") = Cint(DropDownList.Selectedvalue)
dr("intCodigoCliente") = Cint(DropDownList.Selectedvalue)
dr("vchEmail") = Cint(DropDownList.Selectedvalue)
dt_email.Rows.Add(dr)
grdEmail.DataSource = dt_email
grdEmail.DataBind()
Session("dt_email") = dt_email
End Sub
首先,您可以创建一个数据表,或者可以创建一个新的数据表,然后通过添加一行作为所选值来创建数据表DataRow。
毕竟完成后,使用datarow加载数据表。
之后加载带有数据表的网格
First you take a datatable existing OR can create a new one, then create a datatable DataRow this by adding a line as the selected values.
After all done, load the datatable with the datarow.
After that load the grid with datatable