C# 如何将数据表中的数据绑定到Gridview

C# 如何将数据表中的数据绑定到Gridview,c#,asp.net,gridview,C#,Asp.net,Gridview,我将详细说明。我正在尝试获取付款失败的说明,我想将鼠标悬停在图像或状态上,查看付款失败的原因说明: 下面是获取绑定到Gridview的数据的c DataTable BillingDT = new DataTable(); BillingDT = Q.GetBillHistory(SessionVars.Current.varContractID); BillingDT.Columns.Add("PayNum", System.Type.GetType("System.String")); Bi

我将详细说明。我正在尝试获取付款失败的说明,我想将鼠标悬停在图像或状态上,查看付款失败的原因说明:

下面是获取绑定到Gridview的数据的c

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>

如果我正确理解了您的问题,您是否需要绑定图像的工具提示属性?工具提示=


我的问题是使用description,而不是仅仅使用来自SQL表的字段descript。它现在正在工作!!谢谢
<asp:Image ID="StatusIconImg" runat="server" ImageUrl='<%# GetImage((string)Eval("Status")) %>' ToolTip='<%# Eval("description") %>' />