这是我的.aspx页面代码: -
<asp:Button ID="btnProcess" runat="server" Text="Place" OnClick="btnProcess_Click"
CommandArgument='<%# Eval("intId") & "~" & Eval("IdECompleted") & "~" & Eval("dtECompletion") & "~" & Eval("strName") & " " & Eval("strCode") & " " & Eval("strAge") & " " & Eval("strGender") & "~" & Eval("dtStart") & "~" & Eval("strContactP") & "~" & Eval("strAdd") & "~" & Eval("strPhone") & "~" & Eval("intSalary") & "~" & Eval("bitAgree") %> />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我想像下面一样使用它,但会收到错误: -
Private Sub Grd_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Grd.RowDataBound
If Session("poweradmin") = True Then
Dim btnProcess As New Button
btnProcess = CType(e.Row.FindControl("btnProcess"), Button)
btnProcess.CommandArgument = "<% #Eval("intId") & "~" & Eval("IdECompleted") & "~" & Eval("dtECompletion") & "~" & Eval("strName") & " " & Eval("strCode") & " " & Eval("strAge") & " " & Eval("strGender") & "~" & Eval("dtStart") & "~" & Eval("strContactP") & "~" & Eval("strAdd") & "~" & Eval("strPhone") & "~" & Eval("intSalary") & "~" & Eval("bitAgree") %>'"
End If
End Sub
Private Sub Grd_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Grd.RowDataBound
If Session("poweradmin") = True Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim btnProcess As New Button
btnProcess = CType(e.Row.FindControl("btnProcess"), Button)
btnProcess.CommandArgument = DataBinder.Eval(e.Row.DataItem, "intId") & "~" & DataBinder.Eval _
(e.Row.DataItem, "IdECompleted") & "~" & DataBinder.Eval(e.Row.DataItem, "dtECompletion") & "~" & DataBinder.Eval _
(e.Row.DataItem, "strName") & " " & DataBinder.Eval(e.Row.DataItem, "strCode") & " " & DataBinder.Eval _
(e.Row.DataItem, "strCurrAge") & " " & DataBinder.Eval(e.Row.DataItem, "strGender") & "~" & DataBinder.Eval _
(e.Row.DataItem, "dtStart") & "~" & DataBinder.Eval(e.Row.DataItem, "strContactP") & "~" & DataBinder.Eval _
(e.Row.DataItem, "strAdd") & "~" & DataBinder.Eval(e.Row.DataItem, "strPhone") & "~" & DataBinder.Eval _
(e.Row.DataItem, "intSalary") & "~" & DataBinder.Eval(e.Row.DataItem, "bitAgree")
End If
End If
End Sub
答案 0 :(得分:5)
您不能使用字符串表达式,但您可以在后面的代码中评估表达式:
btnProcess.CommandArgument = DataBinder.Eval(e.Row.DataItem, "intId") & " ~ " & DataBinder.Eval(e.Row.DataItem, "IdECompleted")