sagar Bhosale

sagar Bhosale

  • NA
  • 179
  • 176k

just want to show my ArrayList's data(a set of Array) like a table in the GridView control in asp.net using c#

Mar 28 2011 1:29 AM
I use these code below:
GridView1.DataSource = ArrListName
GridView1.DataBind()

This can show my data.However,the GridView control show all of the ArrayList's data in one column named Item,which make the page long and ugly.
I just  want to show my ArrayList's data(a set of Array) like a table in the GridView control .
Can someone help me to solve this problem?
Thanks a lot !


mycaert.cs

if (Session["MyCartItems"] != null) {

//        int ProductId = Convert.ToInt32(Request.QueryString.Get("ProductIdLabel"));

//        ArrayList cart1 = new ArrayList();

//        cart1 = (ArrayList)Session["MyCartItems"];

//        Session["MyCartItems"] = cart1;

//        GridView1.DataSource = cart1;

//        GridView1.DataBind();

//}

mycart.aspx

<asp:GridView ID="GridView1" runat="server" BackColor="Maroon" Datakey="ProductId"
        BorderColor="#660033" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        CellSpacing="2" Width="439px" 
        ShowFooter="True"
        ForeColor="White" > 
          <%--<Columns>

            <asp:BoundField HeaderText="ProductId" ReadOnly="False" />

            <asp:BoundField HeaderText="Product Name" ReadOnly="False" />
            <asp:BoundField DataFormatString="{0:c}" 
                HeaderText="Unit Price" ReadOnly="True" />
            <asp:BoundField HeaderText="Discription" ReadOnly="False" />
            <asp:BoundField HeaderText="Quantity" DataFormatString="{0:c}" />
            <asp:BoundField DataFormatString="{0:c}" 
                HeaderText="Total Price" />--%>
             <%--<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
            <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />--%>
        <%--</Columns>--%>
         </asp:GridView>

         <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ShoppingDBConnectionString %>"
         SelectCommand="SELECT [ProductId],[ProductName],[UnitPrice],[Discription] FROM [Product] WHERE ([ProductId]=@ProductId)"> 
         </asp:SqlDataSource>
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Home.aspx">Back To Home</asp:HyperLink>
&nbsp;</div>
</asp:Content>
  please help me

Answers (1)