ASPXページに次のようなカスタムリンクを作成できます。
<asp:GridView
ID="GridView1"
CssClass="rounded-corner"
runat="server"
AutoGenerateColumns="false"
EnableModelValidation="True"
AllowSorting="True"
onsorting="GridView1_Sorting"
EnableViewState="true"
AllowPaging="True"
PageSize="10"
OnPageIndexChanging="GridView1_PageIndexChanging" >
<Columns>
<asp:BoundField DataField="DATE_ENTERED" HeaderText="Date Submitted" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" />
<asp:BoundField DataField="CLIENT_CLAIM_NUM" HeaderText="Your Claim #" />
<asp:BoundField DataField="PRIMARY_INSURED" HeaderText="Insured" />
<asp:BoundField DataField="PRIMARY_CLAIMANT" HeaderText="Claimant" />
<asp:BoundField DataField="LOB_ID" HeaderText="Type" />
<asp:TemplateField HeaderText="Branch">
<ItemTemplate>
<asp:HyperLink ID="BRANCH_NAME" runat="server" NavigateUrl='<%# "mailto:"+Eval("OWNERS_EMAIL") %>' Text='<%# Eval("BRANCH_NAME") %>' ToolTip='<%#
"<span style=\"text-decoration:underline;\">"+Eval("BRANCH_NAME").ToString().Trim() + "</span><br />" +
Eval("OWNERS_FIRST_NAME").ToString().Trim() + " " +
Eval("OWNERS_LAST_NAME").ToString().Trim() + "<br />" +
Eval("OWNERS_EMAIL").ToString().Trim() + "<br />" +
Eval("OWNERS_OFFICE_PHONE").ToString().Trim() + "<br />" +
Eval("OWNERS_FAX_PHONE").ToString().Trim()
%> '>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
代わりに、私のコードビハインドでこれを直接行う方法はありますか?「計算フィールド」のタイプを作成することによって?
背後にあるコードは次のとおりです。
DbProviderFactory dbf = DbProviderFactories.GetFactory();
using ( IDbConnection con = dbf.CreateConnection() )
{
string sSQL;
// 12/04/2006 Paul. Only include active users.
sSQL = "select top 20 " + ControlChars.CrLf
+ " DATE_ENTERED, CLIENT_CLAIM_NUM, PRIMARY_INSURED, PRIMARY_CLAIMANT, LOB_ID, BRANCH_NAME," + ControlChars.CrLf
+ " OWNERS_FIRST_NAME, OWNERS_LAST_NAME, OWNERS_NAME, OWNERS_EMAIL, OWNERS_OFFICE_PHONE, OWNERS_FAX_PHONE" + ControlChars.CrLf
+ " from vwFILES_DetailViewWithOwners" + ControlChars.CrLf
+ " where 1 = 1 " + ControlChars.CrLf;
using ( IDbCommand cmd = con.CreateCommand() )
{
cmd.CommandText = sSQL;
using ( DbDataAdapter da = dbf.CreateDataAdapter() )
{
((IDbDataAdapter)da).SelectCommand = cmd;
using ( DataTable dt = new DataTable() )
{
da.Fill(dt);
vwMain = dt.DefaultView;
GridView1.DataSource = vwMain;
if ( !IsPostBack )
{
GridView1.DataBind();
}
}
}
}
}
コードビハインドに新しいフィールドを作成して、次のように呼び出すことができますか?
<asp:TemplateField HeaderText="Branch">
<ItemTemplate>
<asp:HyperLink ID="BRANCH_NAME"
runat="server"
NavigateUrl='<%# "mailto:"+Eval("OWNERS_EMAIL") %>'
Text='<%# Eval("BRANCH_NAME") %>'
ToolTip='<%# Eval("MY_CALCULATED_FIELD") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
アドバイスありがとうございます。