Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,
I want to Bind a DataTable By Some field Value.
Example:
My field:
Filed Value
1. Date(DateTime): 2014-08-06
2. Employee Name (txtField): Md Syedur Rahman(combo)
3. Customer Code(combo): 10067(combo)
4.Customer Name(txtField): Md Syedur Rahman(Fill By Auto under Customer Code)
5. District(txtField) : Rajbari(Fill By Auto under Customer Code)

Now I want Bind in DataTable by this Value. How Can I do this.

N.B: Using asp.net c# Websites(Web Application).
Thanks
Md Syedur rahman
Posted
Updated 8-Aug-14 17:30pm
v2

1 solution

/* BUTTON CLICK CODE */


DataTable dataTable = new DataTable();

dataTable .Columns.Add("ColumnName",typeof([what ever data type is]);

//......
//......

// after making all colums add row.

var row = dataTable.NewRow();
row["ColmnName"] = [your value/field/control value etc.. ];

//...... assign rest of fields too.
// aftter it add this row back to dataTable

dataTable.Rows.Add(row);

/*

now you will have a dataTable .. now u can bind it to any control. moreover you can save dataTable in viewState to use it again and again during postbacks and to add multple records in database.

*/
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900