0

有谁知道我如何提取下面标签的值?

            <asp:TemplateField HeaderText="Event Dates">
              <ItemTemplate>
               <asp:Label ID="Label4" runat="server" Text='<%# Bind("eventDates","{0:MM/dd/yyyy}") %>'></asp:Label>
             </ItemTemplate> 
            </asp:TemplateField>

我正在查询数据库并希望在 WHERE 子句中使用标签值。

例如,

这不起作用:

Dim cmd As New SqlCommand("select * from mytable where username= @username and eventDate = @edate", myconn)
cmd.Parameters.AddWithValue("@username", username)
cmd.Parameters.AddWithValue("@edate", Label4.Text)

谢谢

4

1 回答 1

0

You have to get the row first. Then from the row find the control

var label4 = (Label)row.FindControl("Label4");
var labelText = label4.text;
于 2013-06-06T13:57:12.127 回答