For example, the Image of the DataList control must be bound to the specified Image path.
ImageUrl = '<% # Eval ("database field", "admin/uploading/{0}") %>'
Format the specified date field
<Asp: TextBox Id = "TextBox1" Text = '<% # Eval ("database field", "{0: g }") %> 'runat = "server"> </asp: TextBox>
You can use DataFormatString in the binding column of the Gridview. HtmlEncode = "false" should be added to make the DataFormatString settings take effect.
For example: <asp: BoundField DataField = "SignedDate" HeaderText = "signing date" DataFormatString = "{0: d}" HtmlEncode = "false"/>
The key is the letter next to it, which is commonly used below.
D (6/26/2004) D (Saturday, June 26,2004)
T (8:11 PM) T (8:11:04 PM)
G (6/26/2004 8: 11 PM)
G (6/26/2004 8:11:04)
You can bind a value to the CommandArgument attribute of all server buttons in asp.net. For example:
<Asp: Button id = "Button1" CommandArgument = '<% # Eval ("database field name")' runat = "server"> </asp: Button>
If you want to bind multiple values to the trigger button, you can use "~ "Separated, such:
CommandArgument = '<% # Eval ("database field name") + "~ "+ Eval (" database field name ") %>'
On the. cs page, set the value to e. CommandArgument. ToString.
Special usage of data binding expressions
<Asp: Label id = "Label1" Text = '<% # drop-down box ID. SelectedItem. Text %> 'runat = "server">
You can also bind it with a 3-element operation.
For example, <asp: Label id = "Label1" Text = '<% # Eval ("field name"). Tostring () = "False "? "None": Eval ("field name") %>'