HOW TO FILL GRID VIEW WITH OUT USING SQLDATASOURCE AND
PROGRAMING?
Answer Posted / chandra kiran
i think we have to fill the gridview without using SQL datasource???
dataset ds=new dataset();
datatable dt =new datatable();
dt.tablename="SQL";
ds.tables.add(dt);
data column dc1=new datacolumn();
dc1.columnname="SNo";
dc1.datatype=Type.getType("System.Int32");
dt.columns.add(dc1);
//we are added 1 column to our datatable we can achieve this //1 in 1 statement in yhe following way
datacolumn dc2=dt.columns.add("Name",Type.GetType("System.String"));
//so now we have a table with 2 columns(SNo , Name)
//now we have add records to our table
datarow dr1=dt.newrow();
dr1[0]=1;
dr1[1]="kiran";
dt.rows.add(dr1);//we added 1 record
datarow dr2=dt.newrow();
dr2[0]=2;
dr2[1]="varma";
dt.rows.add(dr2);//in the same way we can add rows better //use arrays
//now we have a dataset and a datatable(SQL) inthat one and //this datatable contains two columns & 2 records now we //have to bind this 1 with our gridview
gridview.datasource=ds.tables[0] ;or
gridview.datasource=ds.tables["SQL"];or
gridview.datasource=dt;
output in gridview like
---------------------------------
SNo Name
---------------------------------
1 kiran
2 varma
| Is This Answer Correct ? | 5 Yes | 3 No |
Post New Answer View All Answers
What is ole used for?
What are all the different methods under sqlcommand?
What provider ado.net use by default? Explain the role of data provider in ado.net?
differences between ADO and ADO.NET
If a table contains 20000 records . In a page at each time 100 records to be displayed what are the steps you will take to improve performance? Will you use dataset or datareader?
What is datasource in ado.net?
What is an example of ordinal data?
What is the difference between a datareader and a dataset?
Which method in OLEDBAdapter is used to populate dataset with records?
Data reader read and forward only, how is it possible to get 2 tables of data at a time?
What are the key events of sqlconnection class?
Is bulk insert faster than insert?
Is it possible to load multiple tables in a Dataset?
Which architecture does Datasets follow?
Give an example of a .net application which connects to microsoft access database using ado.net classes.