How can I generate a GridView or DataGrid using only C# in a Command Line application? -
I am adding a command line program that actually runs only on one server automatically, with transaction total Sends a daily email every day.
What would I like to add to the email, instead of displaying the dategrid or gridview in the ASP.net, the specific company name and their totals (rather than the total number for all).
I think I can understand how to get data from DB and use it for it but I am not sure how to keep the grid for the e-mail body. I know that I can keep HTML in an email for an email, but how can I populate it dynamically with information?
I have seen a tutorial with web applications that will do this with an event handler, basically the same GridView from a web form, but I want to do it only with a basic command-line application
var body = "good morning -
tomorrow," + datetime. Now.AddDays (-1). Ostring (" Dddd ") + + + date time.Now update day (-1). ShortStat Straightening () + "There were" + Count. Br> & lt; br / & gt; "+" please & lt; a href = \ "\" "" + Url + "? Date = "+ Date Time.Now Add Add to Day (-1) Change the ShortStat String (). (" / "," - ") +" \ "title = \" Click here to view the transaction. " Gt; "+ url +" & lt; / a & gt; + "& lt; Br / & gt; & Lt; Br / & gt; Company total: & lt; Create and populate a datagrid programmatically for inclusion in our email body; == "The grid goes here";
< Div class = "post-text" itemprop = "text">
You can create a HtmlTable
, which is the one. The net object, dynamically combines the rows and in those rows Add cells, then place HtmlTable
in a string and add it to your email text.
var table = ne W HtmlTable (); var tr = new HtmlTableRow (); Tr.Cells.Add (New HtmlTableCell {InnerText = "Cell Text"}); table.Rows.Add (tr);
You can create the entire table in this way.
Then you can use this function to convert the table into plain text
Personal Stratic String RenderTableToString (HtmlTable table) {(String Vector SW = New StringWriter ()) using ({var htw = New HtmlTextWriter (sw)} {table.RenderControl (htw); Var html = sw.ToString (); HTML return; }}}
Edit: To be able to use the HtmlTable object, you need to add the context of the System.Web
and use it in the application There is a link to go to the statement.
Using System.Web.UI.HtmlControls;
Comments
Post a Comment