开发者

Microformats in ASP.Net WebForms

开发者 https://www.devze.com 2023-03-08 15:11 出处:网络
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. I am using a DataGridView as the table to present this information. T

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. I am using a DataGridView as the table to present this information. This is my "get" 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.

I need to implement microformats for the values returned i.e. instead of

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

you would have

<img clas开发者_StackOverflow中文版s="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.

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. 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.

To conclude, should I even try to microformat given what I'm trying to do, and if so, how should I go about it?

Thanks.


Use an <asp:ListView> instead — it gives you much more control over the HTML output.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号