By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,149 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

Bound Column Question

P: n/a
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>
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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>

Nov 19 '05 #2

P: n/a
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

"Eliyahu Goldin" wrote:
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

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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>


Nov 19 '05 #3

P: n/a
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

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
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

"Eliyahu Goldin" wrote:
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

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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>


Nov 19 '05 #4

P: n/a
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
}
"Eliyahu Goldin" wrote:
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

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
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

"Eliyahu Goldin" wrote:
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

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
> 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>


Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.