そのため、グリッドビューで SQL テーブルの結果を表示しています。一部のフィールドは電話番号です。特定のフィールドは通常の 10 桁の数字ですが、4 桁の内線番号の場合もあります。4 桁の数字の場合は、少なくとも 10 桁の書式設定を適用したくありません。最大で、先頭に Ext: の後にデータを付けたいと思います。これが私がこれまでに持っているものです。私は通常プログラマーではないので、これは Visual Studio のウィザードと Google の結果を組み合わせたものです。ご協力いただきありがとうございます。
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Call Destination" SortExpression="CallDestination">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("CallDestination") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# String.Format("{0:(###) ###-####}",Convert.ToInt64(DataBinder.Eval (Container.DataItem, "CallDestination")))%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:OnCallConnectionString %>" SelectCommand="SELECT [TimeStamp], [CallerID], [Accepted], [CallDestination] FROM [OnCallLog]"></asp:SqlDataSource>
</div>
</form>