如何显示从数据库中的GridView弹出菜单上的每个gridview的行项目? [英] How to show pop up menu from database in gridview on each gridview row items?
问题描述
如何在GridView的每一行项目显示弹出从数据库菜单中的GridView的?
How to show pop up menu from database in gridview on each gridview row items ?
的此实施例是:
<一个href=\"http://www.redbus.in/Booking/SelectBus.aspx?fromCityId=733&fromCityName=Delhi&toCityId=757&toCityName=Manali&doj=26-Dec-2010&busType=Any\" rel=\"nofollow\">http://www.redbus.in/Booking/SelectBus.aspx?fromCityId=733&fromCityName=Delhi&toCityId=757&toCityName=Manali&doj=26-Dec-2010&busType=Any
将光标移动到出发时间和到达时间......一想这类型的GridView项....从数据库中获取项弹出的..
Move your cursor to Departure time and arrival time...a want this type of popup in gridview items....which fetch entries from database..
推荐答案
您可以用JavaScript / jQuery的处理这个问题。 GridView控件本身无关与此有关。
如果我去只是看它建立他有什么我会动态地创建表。这样,你可以使用一个字符串生成器,并在每个td标签之间插入变量名称。您从数据库中检索和存储在一个列表,甚至更好地使用LINQ to SQL的所有数据。
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.
我希望我可以给你在VB中的样本,但这里是什么我谈论的例子。
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();
}
正如你可以看到我code的HTML复选框,然后插入品牌ID到value属性。
As you can see I code the html for a checkbox and insert the brand id into the value attribute.
这篇关于如何显示从数据库中的GridView弹出菜单上的每个gridview的行项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!