client side and server side with datagrid

N

nurit

hi,

My program is going like that:
-choose criteria from dropdownlist
-press on submit bottun
-the results are display in datagrid

Now, here is the problem:
i need to display 4 different datagrids but i only have one on my aspx
file.

i tried to build a dynamic datagrid but couldn't find how to do
that.

i know there is a lot of info at the net but i wasn't able to
understand how to take the datatable with my data and change it to my
datagrid format.
im using c#.
I hope you will be able to help me because im about to give up.
or maybe there is other way to do that????????

this is the datagrid format:

<asp:datagrid id="DataGridRresults" runat="server"
OnPageIndexChanged="DataGridRresults_PageIndexChanged"
BorderStyle="Solid" ShowFooter="True" AllowPaging="True"
BackColor="White" PageSize="5" ForeColor="Black" GridLines="Vertical"
BorderWidth="1px" BorderColor="#999999" CellPadding="3"
HorizontalAlign="Center" AutoGenerateColumns="False">
<FooterStyle BackColor="#CCCCCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#000099"></SelectedItemStyle> <AlternatingItemStyle
BackColor="#CCCCCC"></AlternatingItemStyle>
<ItemStyle Wrap="False" HorizontalAlign="Center"
VerticalAlign="Top"></ItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False" HorizontalAlign="Center"
ForeColor="White" VerticalAlign="Middle"
BackColor="Black"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Company Name">
<ItemTemplate>
<a HREF='' onClick='window.open("<%#
Convert.ToString(DataBinder.Eval(Container.DataItem, "url"))%>",
"_blank",
"width=730,height=500,menubar=no,location=no,toolbar=no,status=yes,scrollbars=yes,resizable=yes");return
false;'><%# DataBinder.Eval(Container.DataItem, "Topic")%>
</a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="E-Mail">
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<B>
<%# DataBinder.Eval(Container.DataItem, "Companyname") %>
</B>
<BR>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Business Phone">
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<B>
<%# DataBinder.Eval(Container.DataItem, "BusinessPhone") %>
</B>
<BR>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Mobile Phone">
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<B>
<%# DataBinder.Eval(Container.DataItem, "MobilePhone") %>
</B>
<BR>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999" Mode="NumericPages"></PagerStyle>
</asp:datagrid>

thanks
nurit
 
N

nurit

i found the answer for me. if any one wants to know its goes like that:
codebehind:

BoundColumn col = new BoundColumn();

for (int i=0; i<DTcolumns.Length;i++)
{
col = new BoundColumn();
col.DataField = DTcolumns;
col.HeaderText = DTcolumns;
DataGridRresults.Columns.Add(col);
}

DataGridRresults.DataSource = workTable;
DataGridRresults.DataBind();
DataGridRresults.Visible=true;

aspx file:

<asp:datagrid id="DataGridRresults" runat="server"
OnPageIndexChanged="DataGridRresults_PageIndexChanged"
BorderStyle="Solid" ShowFooter="True" AllowPaging="True"
BackColor="White" PageSize="5" ForeColor="Black"
GridLines="Vertical" BorderWidth="1px" BorderColor="#999999"
CellPadding="3" HorizontalAlign="Center"
AutoGenerateColumns="False">
<FooterStyle BackColor="#CCCCCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#000099"></SelectedItemStyle>
<AlternatingItemStyle
BackColor="#CCCCCC"></AlternatingItemStyle>
<ItemStyle Wrap="False" HorizontalAlign="Center"
VerticalAlign="Top"></ItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False"
HorizontalAlign="Center" ForeColor="White" VerticalAlign="Middle"
BackColor="Black"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Company Name">
<ItemTemplate>
<a HREF=''
onClick='window.open("<%#
Convert.ToString(DataBinder.Eval(Container.DataItem, "url"))%>",
"_blank","width=730,height=500,menubar=no,location=no,toolbar=no,status=yes,scrollb­ars=yes,resizable=yes");return
false;'>
<%# DataBinder.Eval(Container.DataItem, "Topic")%>
</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top