Click here to Skip to main content
15,908,013 members
Home / Discussions / C#
   

C#

 
AnswerRe: richtextbox Pin
Raj Mouli28-Feb-14 22:00
Raj Mouli28-Feb-14 22:00 
QuestionYou can define columns for a temporary DataTable? Pin
Souza-1063377928-Feb-14 8:34
Souza-1063377928-Feb-14 8:34 
Confused | :confused:

Friends, good morning everyone.
I am needing to define the columns and their characteristics to a temporary DataTable, and not let it generates the columns, the data are inserting correctly, I have my grid:


C#
<asp:GridView ID="GridResumoTotal" runat="server" Height="2px"
Width="100%" AutoGenerateColumns="true" >
</asp:GridView>


I wanted to set my grid with the fields and formatting without using AutoGenerateColumns
I greatly appreciate the help!

I'm doing this:

C#
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
//dataTable para guarda dados temporario
dtb = CriaDataTable();
Session["mDatatable"] = dtb;
GridResumoTotal.DataSource = ((DataTable)Session["mDatatable"]).DefaultView;
GridResumoTotal.DataBind();
}

//criar um DataTable temporário
private DataTable CriaDataTable()
{
DataTable mDataTable = new DataTable();
DataColumn mDataColumn;

mDataColumn = new DataColumn();
mDataColumn.DataType = Type.GetType("System.String");
mDataColumn.ColumnName = "MODALIDADE";
mDataTable.Columns.Add(mDataColumn);

mDataColumn = new DataColumn();
mDataColumn.DataType = Type.GetType("System.String");
mDataColumn.ColumnName = "QTD_OBJ_16";
mDataTable.Columns.Add(mDataColumn);

mDataColumn = new DataColumn();
mDataColumn.DataType = Type.GetType("System.String");
mDataColumn.ColumnName = "QTD_OBJ_17";
mDataTable.Columns.Add(mDataColumn);

return mDataTable;
}

private void incluirNoDataTable(string modalidade, string qtd_obj16, string qtd_obj_17, DataTable mTable)
{
DataRow linha;
linha = mTable.NewRow();
//gera o número GUID
//linha["CODIGO"] = Guid.NewGuid().ToString();
linha["MODALIDADE"] = modalidade;
linha["QTD_OBJ_16"] = qtd_obj16;
linha["QTD_OBJ_17"] = qtd_obj_17;
mTable.Rows.Add(linha);
}


GridResumoTotal.Columns.Clear();
incluirNoDataTable("TOTAL GERAL DIA : ", footer.Cells[16].Text,footer.Cells[17].Text, (DataTable)Session["mDatatable"]);
GridResumoTotal.DataSource = ((DataTable)Session["mDatatable"]).DefaultView;
GridResumoTotal.DataBind();

AnswerRe: You can define columns for a temporary DataTable? Pin
Mycroft Holmes28-Feb-14 12:59
professionalMycroft Holmes28-Feb-14 12:59 
QuestionC # if statement (parameter read form sql Server DB) Pin
Member 1063374328-Feb-14 8:16
Member 1063374328-Feb-14 8:16 
AnswerRe: C # if statement (parameter read form sql Server DB) Pin
Richard Deeming28-Feb-14 8:27
mveRichard Deeming28-Feb-14 8:27 
GeneralRe: C # if statement (parameter read form sql Server DB) Pin
Member 1063374328-Feb-14 8:36
Member 1063374328-Feb-14 8:36 
GeneralRe: C # if statement (parameter read form sql Server DB) Pin
Member 104046945-Mar-14 21:29
Member 104046945-Mar-14 21:29 
AnswerRe: C # if statement (parameter read form sql Server DB) Pin
ZurdoDev28-Feb-14 10:56
professionalZurdoDev28-Feb-14 10:56 
QuestionMessage Closed Pin
27-Feb-14 20:31
Member 1063210727-Feb-14 20:31 
AnswerRe: plz Pin
V.27-Feb-14 20:46
professionalV.27-Feb-14 20:46 
AnswerRe: plz Pin
Bernhard Hiller27-Feb-14 20:48
Bernhard Hiller27-Feb-14 20:48 
AnswerRe: plz Pin
ScottM127-Feb-14 20:53
ScottM127-Feb-14 20:53 
AnswerRe: plz Pin
GuyThiebaut27-Feb-14 22:01
professionalGuyThiebaut27-Feb-14 22:01 
GeneralRe: plz Pin
Richard MacCutchan27-Feb-14 22:14
mveRichard MacCutchan27-Feb-14 22:14 
AnswerRe: plz PinPopular
Pete O'Hanlon28-Feb-14 0:29
mvePete O'Hanlon28-Feb-14 0:29 
GeneralRe: plz Pin
Wayne Gaylard28-Feb-14 1:59
professionalWayne Gaylard28-Feb-14 1:59 
AnswerRe: plz Pin
Ennis Ray Lynch, Jr.28-Feb-14 5:15
Ennis Ray Lynch, Jr.28-Feb-14 5:15 
QuestionHow to click on a node in treeview and display and edit data in listview Pin
daddy35627-Feb-14 18:14
daddy35627-Feb-14 18:14 
AnswerRe: How to load an xml into a treeview then when clicked on an item shows in listview Pin
BillWoodruff27-Feb-14 21:51
professionalBillWoodruff27-Feb-14 21:51 
AnswerRe: How to click on a node in treeview and display and edit data in listview Pin
BillWoodruff1-Mar-14 14:13
professionalBillWoodruff1-Mar-14 14:13 
AnswerRe: How to click on a node in treeview and display and edit data in listview Pin
BillWoodruff8-Mar-14 4:04
professionalBillWoodruff8-Mar-14 4:04 
GeneralRe: How to click on a node in treeview and display and edit data in listview Pin
daddy3569-Mar-14 12:04
daddy3569-Mar-14 12:04 
GeneralRe: How to click on a node in treeview and display and edit data in listview Pin
BillWoodruff9-Mar-14 21:04
professionalBillWoodruff9-Mar-14 21:04 
GeneralRe: How to click on a node in treeview and display and edit data in listview Pin
daddy3569-Mar-14 21:19
daddy3569-Mar-14 21:19 
GeneralRe: How to click on a node in treeview and display and edit data in listview Pin
BillWoodruff9-Mar-14 21:41
professionalBillWoodruff9-Mar-14 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.