asp.net - How do I replace the checkboxes in my C# excel export to ones and zeros? -


In a C # application I have created a GridView dynamically and exported it to Excel is. The problem I'm having is that since the three fields have bit columns in the SQL, they export as checkboxes and not the zero. I have searched something on Google for similar issues and found this solution. However, it will not work after right or left click on the object, because it checks or unchecks the box

I have information about exporting the beat field from C # to 1 and 0 Attempted to get and nothing is found. Here is my export script:

  stringwriter author = new stringwriter (); HtmlTextWriter htmlWriter = new HtmlTextWriter (author); Gridview Gridview = New Gridview (); GridView.DataSource = sdsResults; GridView.AutoGenerateColumns = True; GridView.DataBind (); GridViewHeaderRow.Style.Add ("background-color", "# 003c74"); GridView.HeaderRow.Style.Add ("Color", "#ffffff"); {GridViewRow line = gridView.Rows [i] for (Int i = 0; i & lt; gridView.Rows.Count; i ++); // Change the color back in white color. Backside = System Drawing Collar White; // Apply the text style to each line line. a quality. Add ("square", "text mode"); // apply style to the individual room of Alerting Row if (i% 2! = 0) {row.BackColor = System.Drawing.Color.AliceBlue; } Foreach (cell table cell in row). {If (cell.HasControls () == true) {if (cell.Controls [0] .GetType (.) ToString () == "System.Web.UI.WebControls checkbox") {checkbox chk = (checkbox) cell . Control [0]; If (chk.checked) {cell. Text = "1"; } And {cell.Text = "0"; }}}}} GridView.RenderControl (htmlWriter); HtmlWriter.Close (); Response.Clear (); Response.AddHeader ("content-type", "attachment; file name = myfile.xls"); Response. Charset = ""; Response.Write (writer.ToString ()); Rispans.and (); Rispans.and (); In the loop,  

, you can do something like this:

< Pre> foreach (cellcell cell in table cell) {if (cell.HasControls () == true) {if (cell.Controls [0] .GetType (). ToString () == "System.Web UI .WebControls.CheckBox ") {checkbox chk = (checkbox) cell. Control [0]; If (chk.checked) {cell. Text = "1"; } And {cell.Text = "0"; }}}}

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -