1
Answer

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

sagar Bhosale

sagar Bhosale

14y
1.6k
1
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)
0
Kunal Vaishya
NA 4.1k 266.1k 12y

Attachment moviedb.zip

0
Waqas Ali
NA 19 19.4k 12y
Thanks,
Can you tell me how to use this command with a textbox

regionTableAdapter.Insert(5, "NorthWestern");

can i write textbox1.text, textbox2.text instead of 5 and Northwestern. I tried it but it gave me error( I was explicitly converting the textboxes to int32)

????
0
Satyapriya Nayak
NA 53k 8m 12y
Hi Waqas,

Please refer the below links

http://www.c-sharpcorner.com/uploadfile/mimrantaj/connect-to-access-database-in-C-Sharp-and-ado-net/

http://msdn.microsoft.com/en-us/library/aa288452%28v=vs.71%29.aspx

http://www.codeproject.com/Articles/24043/Simple-Movie-Database-in-C-using-Microsoft-Access

Thanks