Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Gary Frank #1
Bound datatable + unbound column in datagrid
Is is possible to create an ASP.NET datagrid that mixes bound data
pulled from a database table with an unbound column created by the
program?
I would like to display several columns from an SQL Server database
table (table 1) in an ASP.NET datagrid control. I would also like to
display an additional column in the datagrid. The value for the
additional column would be generated by plugging values from a couple
of columns in the row in table 1 into an SQL SELECT query that selects
rows from a different table (table 2), and then performs a calculation
that produces the value for the additional column. (The value for the
additional column in each row is based on values in other columns in
that row that came from table 1.) I want the user to be able to use
the edit, update and delete buttons in the datagrid to process the
columns that came from table 1, but not table 2.
Is this possible? Can you add an unbound column to a table that is
bound to a database table? And if you do so, can you use the edit,
update, delete buttons in the datagrid to update the datasource (the
database table) for the columns that came from table 1?
What would be the best way to go about this? Would it be best to
generate a dataset from a data adapter, then add a column to the
datatable in the dataset? I think you have to do this programatically.
Would you then bind the dataset/datatable to the datagrid?
Or can you bind a datatable to a datagrid, then add an additional
column to the datagrid? If you did this, could you do a SELECT on
table 2 in order to create the value for the additional column?
Gary Frank Guest
-
Move bound column to right of dynamic column in datagrid?
I have a datatable that I am binding to a C# ASP.NET 1.1 web page. I also want to put an "Edit" column on the datagrid. However, whenever I use... -
datagrid cell and bound column
Hi, i've registered a week ago at the managed newsgroups, but I didn't get a mail that the registration was ok. So I hope my question is answered. ... -
Binding Two DataTable Columns to One DataGrid Column
I have a DataTable that I am binding to a DataGrid. I need to take two columns in the DataTable, and bind them to one row in the DataGrid (for... -
Bound Column or Template Column (w dAdapater?) in DataGrid
I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL... -
Trying to hide a datatable column from my datagrid... please help
I've read everywhere to use the following: objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden objDS.AcceptChanges() ... -
Elton Wang #2
Re: Bound datatable + unbound column in datagrid
Hi Gary,
Normally you can use JOIN query get records from multi-tables.
If the logic to get the additional column is very complicated, you can query
table1 and have an empty 'reserved' column first, like follows:
Select column_1, column_2, ., '' As additional_column_name From table1 Where
Condition
After fill the query result to a DataTable, you can either
Loop thru rows in the DataTable to perform calculation for the column, then
bind the datatable to datagrid
Or bind the datatable to datagrid, then to perform calculation for the
column in datagrid_ItemDataBound event.
HTH
"Gary Frank" <gary-frank@sbcglobal.net> wrote in message
news:1124984098.925059.74710@z14g2000cwz.googlegro ups.com...> Is is possible to create an ASP.NET datagrid that mixes bound data
> pulled from a database table with an unbound column created by the
> program?
>
> I would like to display several columns from an SQL Server database
> table (table 1) in an ASP.NET datagrid control. I would also like to
> display an additional column in the datagrid. The value for the
> additional column would be generated by plugging values from a couple
> of columns in the row in table 1 into an SQL SELECT query that selects
> rows from a different table (table 2), and then performs a calculation
> that produces the value for the additional column. (The value for the
> additional column in each row is based on values in other columns in
> that row that came from table 1.) I want the user to be able to use
> the edit, update and delete buttons in the datagrid to process the
> columns that came from table 1, but not table 2.
>
> Is this possible? Can you add an unbound column to a table that is
> bound to a database table? And if you do so, can you use the edit,
> update, delete buttons in the datagrid to update the datasource (the
> database table) for the columns that came from table 1?
>
> What would be the best way to go about this? Would it be best to
> generate a dataset from a data adapter, then add a column to the
> datatable in the dataset? I think you have to do this programatically.
> Would you then bind the dataset/datatable to the datagrid?
>
> Or can you bind a datatable to a datagrid, then add an additional
> column to the datagrid? If you did this, could you do a SELECT on
> table 2 in order to create the value for the additional column?
>
Elton Wang Guest
-
Gary Frank #3
Re: Bound datatable + unbound column in datagrid
Elton,
Thank you Elton! I didn't realize you could do an SQL query that
returns an empty column. It looks like a very clean solution. I'm
wondering how this will work if I add the edit, update and delete
buttons to the Datagrid. Will the empty column cause an error when
these datagrid buttons attempt to update the datasource table?
Gary Frank
--
Sent via .NET Newsgroups
[url]http://www.dotnetnewsgroups.com[/url]
Gary Frank Guest
-
Elton Wang #4
Re: Bound datatable + unbound column in datagrid
Hi Gary,
I don't think there are any troubles in Update/Delete logic, (Edit only
works on web controls, no direct connection with DB). You can easily control
to select data from proper columns for updating/deleting data in DB.
HTH
"Gary Frank" <gary-frank@sbcglobal.net> wrote in message
news:e%23feJVaqFHA.1328@tk2msftngp13.phx.gbl...> Elton,
>
> Thank you Elton! I didn't realize you could do an SQL query that
> returns an empty column. It looks like a very clean solution. I'm
> wondering how this will work if I add the edit, update and delete
> buttons to the Datagrid. Will the empty column cause an error when
> these datagrid buttons attempt to update the datasource table?
>
> Gary Frank
>
> --
> Sent via .NET Newsgroups
> [url]http://www.dotnetnewsgroups.com[/url]
Elton Wang Guest



Reply With Quote

