Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
c# から GridView の列の形式を変更する方法
Label lblDate= (Label)(e.Row.FindControl("lblDate")); if (lblDate!= null) { lblDate.Text = (string)DataBinder.Eval(e.Row.DataItem, "event_start"); }
<asp:BoundField>グリッド ビューの要素で、設定します。DataFormatString="xxx"
<asp:BoundField>
DataFormatString="xxx"
ここで、「xxx」はフォーマット文字列です。たとえばDataFormatString="{0:C}"、デフォルトの通貨記号と小数点以下 2 桁などで通貨としてフォーマットされます。
DataFormatString="{0:C}"
すべての標準書式設定オプションについては、BoundField.DataFormatString の MSDN ヘルプを確認してください。