我如何从我的数据表绑定数据Gridview



我将详细说明。我正试图获得一个失败的付款描述,我想悬停在图像或状态,看看支付失败的原因描述:

这是c#获取绑定到Gridview的数据

DataTable BillingDT = new DataTable();
BillingDT = Q.GetBillHistory(SessionVars.Current.varContractID);
BillingDT.Columns.Add("PayNum", System.Type.GetType("System.String"));
BillingDT.Columns.Add("DateStr", System.Type.GetType("System.String"));
BillingDT.Columns.Add("AmountStr", System.Type.GetType("System.String"));
BillingDT.Columns.Add("BalanceStr", System.Type.GetType("System.String"));
BillingDT.Columns.Add("description", System.Type.GetType("System.String"));
string DownPayment = DT.Select("Name = 'DownPayment'")[0][1].ToString();
for (int row = 0; row < BillingDT.Rows.Count; row++)
{
    BillingDT.Rows[row]["PayNum"] = BillingDT.Rows[row]["Payment"].ToString();
    BillingDT.Rows[row]["DateStr"] = Convert.ToDateTime(BillingDT.Rows[row]["paydate"]).ToShortDateString();
    if (BillingDT.Rows[row]["payment"].ToString() == "0") { 
        BillingDT.Rows[row]["PayNum"] = DownPayment; 
    }
    if (BillingDT.Rows[row]["status"].ToString().Length < 1) {
        BillingDT.Rows[row]["status"] = "";
    }
    if (BillingDT.Rows[row]["descript"].ToString().Length < 1) {
        BillingDT.Rows[row]["description"] = "";
    }
    if (BillingDT.Rows[row]["amount"].ToString().Length > 0) { 
        BillingDT.Rows[row]["AmountStr"] = FV.MoneyString(Convert.ToDecimal(BillingDT.Rows[row]["amount"])); 
    }
    BillingDT.Rows[row]["BalanceStr"] = (BillingDT.Rows[row]["balance"].ToString().Length > 0) ? FV.MoneyString(Convert.ToDecimal(BillingDT.Rows[row]["balance"])) : "";
}
BillingHistoryGV.DataSource = BillingDT;
BillingHistoryGV.DataBind();

,这里是ASP:Image,我想将它的描述绑定到工具提示:

<asp:TemplateField>
    <ItemTemplate>
        <asp:Image ID="StatusIconImg" runat="server" ImageUrl='<%# GetImage((string)Eval("Status")) %>' />
    </ItemTemplate>
    <ItemStyle HorizontalAlign="Right" Width="20px" />
</asp:TemplateField>

如果我正确理解你的问题,你不需要绑定你的图像的ToolTip属性吗?ToolTip='<%# Eval("description") %>'

<asp:Image ID="StatusIconImg" runat="server" ImageUrl='<%# GetImage((string)Eval("Status")) %>' ToolTip='<%# Eval("description") %>' />

最新更新