【发布时间】:2018-02-19 13:39:48
【问题描述】:
当我点击投票按钮时,将插入详细信息,但我只想要插入特定按钮点击数据的所有页面详细信息。
代码:
Protected Sub vote(sender As Object, e As EventArgs) {
//( lblName,lbl_id ,lbl_name,Label1 this is all reapeater field id )
Dim lblName As Label
Dim lbl_id As Label
Dim lbl_name As Label
Dim Label1 As Label
For Each item As RepeaterItem In rpt_path.Items
lblName = CType(item.FindControl("lblName"), Label)
lbl_id = CType(item.FindControl("lbl_id"), Label)
lbl_name = CType(item.FindControl("lbl_name"), Label)
Label1 = CType(item.FindControl("Label1"), Label)
con=("Connection String")
con.Open()
Dim command As New OleDbCommand("insert into CFC(C_E_No,Name,Class_id,Party_id)values(@C_E_No,@Name,@Class_id,@Party_id)", con)
command.Parameters.AddWithValue("(@C_E_No", CType(item.FindControl("lblName"), Label).Text)
command.Parameters.AddWithValue("@Name", CType(item.FindControl("lbl_id"), Label).Text)
command.Parameters.AddWithValue("@Class_id", CType(item.FindControl("lbl_name"), Label).Text)
command.Parameters.AddWithValue("@Party_id", CType(item.FindControl("Label1"), Label).Text)
command.ExecuteNonQuery()
con.Close()
【问题讨论】:
-
很确定你不想为每个重复所有的RepeaterItems。没有那个代码很难说。
-
我们能看到转发器标记的源代码吗?
-
您要插入所有数据吗?为了回答这个问题,我需要更清楚一些。如果您只想插入特定数据,则只需将该特定数据传递给查询或过程。