client side and server side with datagrid

Discussion in 'ASP .Net' started by nurit, Apr 5, 2005.

  1. nurit

    nurit Guest

    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
     
    nurit, Apr 5, 2005
    #1
    1. Advertising

  2. nurit

    nurit Guest

    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>
     
    nurit, Apr 5, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page