Bound Column Question

G

Guest

i have datagrid , I added a bound column and I need to map it with two data
fields ...is this possible?

<asp:datagrid id=dgInbox runat="server" EnableViewState="False"
AutoGenerateColumns="False" AllowSorting="True" Width="100%">
<ItemStyle Wrap="False" BorderWidth="11px" BorderStyle="Solid"
CssClass="tableCell"></ItemStyle>
<HeaderStyle Height="26px" CssClass="tableHeaderCell"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="subject" SortExpression="subject"
HeaderText="Subject"></asp:BoundColumn>

<!-- here i need to map the bound column to second field "name" ...is this
possible" -->
</asp:datagrid>
 
E

Eliyahu Goldin

What do you want to achieve? If you want to merge values from two database
fields to one column, you can do it with a TemplateColumn.

Eliyahu
 
G

Guest

I'm retrieving a datatable from a 1st webservice with following structure
(Subject(string),Date(DateTime))

and retrieving a dataset from 2nd webservice with one table of following
structure
(Name(string),Date(DataTime))

I need to list the Subject and Name in same column of datagrid
 
G

Guest

I did following to merge them to one datatable ...but i seeks better way if any

DataTable dtMerged = new DataTable("MergedTable");
dtMerged.Columns.Add("subject",typeof(string));
dtMerged.Columns.Add("date",typeof(DateTime));
dtMerged.Columns.Add("size",typeof(double));
DataSet dsDoc =oWS1.GetUserFoldersInfo("doc");
DataTable dtMessages = oWS2.GetUsersFolder("doc");
int nRowsCount = dsDoc.Tables[0].Rows.Count;

for(int index = 0 ; index < nRowsCount ; index++)
{
DataRow drDoc = dtMerged.NewRow();

foreach(DataColumn MergedColumn in dtMerged.Columns)
{
if(MergedColumn.ColumnName.Equals("subject"))
{
drDoc[MergedColumn] = dsDoc.Tables[0].Rows[index][0];
}
}

//And so on for the second table
}
 
E

Eliyahu Goldin

You can't mix 2 datasources in the same grid. You need to create a DataTable
where you will merge records from 2 datasources in runtime and databind to
this table.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top