How to show pop up menu from database in gridview on each gridview row items?

后端 未结 2 1183
忘掉有多难
忘掉有多难 2020-12-22 09:05

How to show pop up menu from database in gridview on each gridview row items ?

Example of this is :

http://www.redbus.in/Booking/SelectBus.aspx?fromCityId=73

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 09:45

    You can handle this with javascript/jQuery. The gridview itself has nothing to do with this.

    If I was going to build what he has just by looking at it I would create the table dynamically. This way you could use a string builder and insert variable names in between each td tag. You retrieve all your data from the database and store in a List or even better use LINQ to SQL.

    I wish I could give you a sample in VB, but here is an example of what I'm talking about.

    protected void Page_Load(object sender, EventArgs e)
    {
        StoreDataContext db = new StoreDataContext();
        var join = from b in db.Brands      
                   select new
                   {
                       Brand = b,
    
                       c = b.Description.Length < 204 ? b.Description : b.Description.Substring(0, 204) + "...",
                       Sources = 
                            from s in db.Sources
                            join xref in db.Brands_Sources on s.SourceID equals xref.SourceID
                            where xref.BrandID == b.BrandID
                            select s       
                   };
        StringBuilder sb = new StringBuilder();
    
        sb.Append( "");
        sb.Append( "");
    
        foreach (var result in join)
        {
            string chk = (result.Brand.Active ? "checked='checked'" : "");
            sb.AppendFormat( "" +
                    "", chk, result.Brand.Image, result.Brand.Name, result.c,result.Brand.BrandID);
            sb.Append("");
            sb.AppendFormat("", date, mod);
        }
        sb.Append("
    ActiveImageNameShort DescriptionSourceDate CreatedData Modified
    {2}{3}"); foreach (var q in result.Sources) { string srcname = (q.Source1=="Motovicity" ? "Motovicity":"Direct"); sb.AppendFormat("", q.Image,srcname); } string date = string.Format("{0:MM/dd/yy}", result.Brand.DateCreated); string mod = string.Format("{0:MM/dd/yy}", result.Brand.DateModified); sb.Append("{0}{1}
    "); resultSpan.InnerHtml = sb.ToString(); }

    As you can see I code the html for a checkbox and insert the brand id into the value attribute.

提交回复
热议问题