简体   繁体   English

ASP.Net WebForms 中的微格式

[英]Microformats in ASP.Net WebForms

I am writing a basic search feature that searches for a string in a SQL DB, and then returns the rows where the string is present.我正在编写一个基本搜索功能,在 SQL DB 中搜索字符串,然后返回字符串所在的行。 I am using a DataGridView as the table to present this information.我使用 DataGridView 作为表格来呈现这些信息。 This is my "get" function:这是我的“得到” function:

public void DisplaySearchResults(string searchStr)
    {
        SqlCommand cmd = new SqlCommand("Vendor_SearchVendor",
        new SqlConnection("connection string here"));
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@SearchString", searchStr);
        cmd.Connection.Open();

        SearchTable.DataSource = cmd.ExecuteReader();
        SearchTable.DataBind();

        cmd.Connection.Close();
        cmd.Connection.Dispose();
    }

where SearchTable is the DataGridView.其中 SearchTable 是 DataGridView。

I need to implement microformats for the values returned ie instead of我需要为返回的值实现微格式,即而不是

<img src="www.example.com/bobsmith.jpg" />

you would have你将会拥有

<img class="photo" src="www.example.com/bobsmith.jpg" />

I follow how to do this for standard HTML, but the data grid has an tag and the different columns have tags, and I can't add the microformat tags to them.我遵循如何为标准 HTML 执行此操作,但数据网格有一个标签,不同的列有标签,我无法向它们添加微格式标签。

I thought about converting the DataGrid to HTML, but that solution would involve having a data grid table constantly present, which is not what we want.我曾考虑将 DataGrid 转换为 HTML,但该解决方案将涉及不断存在数据网格表,这不是我们想要的。 In fact, I don't think microformatting here makes sense because, as I understand, microformats are for static text and the data here may or may not be generated based on the display shown.事实上,我认为这里的微格式没有意义,因为据我了解,微格式适用于 static 文本,这里的数据可能会或可能不会根据显示的显示生成。

To conclude, should I even try to microformat given what I'm trying to do, and if so, how should I go about it?最后,鉴于我正在尝试做的事情,我是否应该尝试微格式,如果是这样,我应该如何 go 关于它?

Thanks.谢谢。

Use an <asp:ListView> instead — it gives you much more control over the HTML output.改用<asp:ListView> — 它让您可以更好地控制 HTML output。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM