开发者

c# - Click on link to create a table?

Hmmm not sure how to exactly ask this.

What i want to do is to be able to click on a link called surname and then below i want a table generated with a list of everyone with that surname from the database.

<input type="text" id="surname" name="surname" size="10" /><a href="javascript:surname();">Surname</a> 
        <input type="text" id="forename" name="forename" size="10" /><a href="javascript:forename();">Forename</a> 

        <table id = "t" visible="false" runat="server">
        <tr>
            <th>Surname</th>
            <th>Forename</th>
            <th>D.O.B</th>
        </tr>
        </table>

To get the data the quesry se开发者_Python百科lect * from surname will return surname, forname and d.o.b

This is roughly what i have at the moment. I know i have to call a function somwhere and then return something to generate the data in side the table 't' but how?


Not sure if im getting what you want, but i convert datatables to html tables thus. Hope it helps.

public string WriteResult(DataTable dt)
{

    DataGrid dg = new DataGrid();
    dg.CellPadding = 5;
    dg.BackColor = System.Drawing.Color.White;
    dg.BorderColor = System.Drawing.Color.Gray;
    dg.Font.Name = "Arial";
    dg.Font.Size = FontUnit.XSmall;
    dg.HeaderStyle.Font.Bold = true;
    dg.FooterStyle.Font.Bold = true;

    dg.DataSource = dt;
    dg.DataBind();

    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);

    dg.RenderControl(hw);

    return sw.ToString();

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜