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

后端 未结 2 1163
忘掉有多难
忘掉有多难 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:44

    He is not fetching record on runtime basically if you see the structure he has the information in the tooltip attribute of anchor tag and using jquery cluetip to display it.

    so you can use any jquery tooltip plugin to display same as he is doing.

    Thanks

    0 讨论(0)
  • 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( "<table class='tableStripe'>");
        sb.Append( "<tr><th width='1%'>Active</th><th>Image</th><th>Name</th><th>Short Description</th><th>Source</th><th width='1%'>Date Created</th><th width='1%'>Data Modified</th></tr>");
    
        foreach (var result in join)
        {
            string chk = (result.Brand.Active ? "checked='checked'" : "");
            sb.AppendFormat( "<tr><td><input class='brandChk' value='{4}' type='checkbox' {0}></td><td width='1%'><img width='50px' src='{1}'</img></td>" +
                    "<td><a href='/admin/Catalog/Brand/Detail.aspx?brandId={4}'>{2}</a></td><td width='60%'>{3}</td>", chk, result.Brand.Image, result.Brand.Name, result.c,result.Brand.BrandID);
            sb.Append("<td>");
                foreach (var q in result.Sources)
                {
                    string srcname = (q.Source1=="Motovicity" ? "Motovicity":"Direct");
                    sb.AppendFormat("<img src='{0}' title='{1}'</img>", 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("</td>");
            sb.AppendFormat("<td>{0}</td><td>{1}</td></tr>", date, mod);
        }
        sb.Append("</table>");
        resultSpan.InnerHtml = sb.ToString();
    }
    

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

    0 讨论(0)
提交回复
热议问题