gpt4 book ai didi

c# - 在代码隐藏中设置 Eval

转载 作者:太空宇宙 更新时间:2023-11-03 20:28:59 25 4
gpt4 key购买 nike

这是我的 .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

最佳答案

你不能使用字符串表达式,但你可以在代码后面计算一个表达式:

btnProcess.CommandArgument =  DataBinder.Eval(e.Row.DataItem, "intId") & " ~ " & DataBinder.Eval(e.Row.DataItem, "IdECompleted")

关于c# - 在代码隐藏中设置 Eval,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8622977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com