English 中文(简体)
在一份名单内向GredView发送名单
原标题:Binding a List inside of a List to a GridView

我有一个拥有各类不同数据成员的类别,包括一个图表清单。 当我把数据与GridView联系起来时,我希望能够把插图清单分为GridView的不同栏目。 这些限制更像旗帜,最多有3条旗帜。 如果没有旗帜,名单可能空洞,或只载有一或两条旗帜。 我怎么能够将这些旗帜分到不同的格里德文栏中? 我是否需要在翁韦达塔博迪活动中这样做?

目前,我的牛奶法典就是这样。 我希望能够根据是否提高国旗而改变图像控制的形象。

<asp:TemplateField HeaderText="Tax" SortExpression="Tax">
    <ItemTemplate>
        <asp:Image ID="imgTax" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

    <asp:TemplateField HeaderText="Compliance" SortExpression="Compliance">
    <ItemTemplate>
        <asp:Image ID="imgCompliance" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

    <asp:TemplateField HeaderText="Accounting" SortExpression="Accounting">
    <ItemTemplate>
        <asp:Image ID="imgAccounting" runat="server" />
    </ItemTemplate>
</asp:TemplateField>

感谢!

最佳回答

是否有办法修改你的数据,以便将这些扼杀变成ole? 以这种方式使用扼杀我,把它当作一种手法。 从个人角度来说,我将把这些扼杀变成你作为电网数据来源而重新使用的那类 class,并修改其标识上的可见性,而不是回到数据库,逐行选择这些特性。

不管怎样,你们都可以利用罗达塔博迪活动,如:

yourGrid_RowDataBound(object sender, EventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        YourClass currentClass = (YourClass) e.Row.DataItem;

        for (int i = 0; i < currentClass.stringFlags.Length; i++)
        {
            string currentFlag = currentClass.stringFlags[i];

            if (currentFlag == "Tax")
            {
                Image imgTax = (Image) e.Row.FindControl("imgTax");
                imgTax.Visbile = true;
            }
            else if (currentFlag == "Compliance")
            {
                Image imgCompliance = (Image) e.Row.FindControl("imgCompliance");
                imgCompliance.Visbile = true;
            }
            else if (currentFlag == "Accounting")
            {
                Image imgAccounting = (Image) e.Row.FindControl("imgAccounting");
                imgAccounting.Visbile = true;
            }
        }
    }
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签