Click here to Skip to main content
15,918,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello sir.
i have a folder that had 50 images. i have a gridview code is below

XML
<asp:GridView ID="GV" runat="server" AutoGenerateColumns ="false" >

                        <Columns >
                            <asp:BoundField HeaderText ="ID" DataField ="id"/>
                            <asp:TemplateField HeaderText ="IMAGE">
                                <ItemTemplate>

                                    <asp:Image ID="Img" runat="server" ImageUrl="image" Width="50" Height="50"/> <br />
                                    <asp:Button ID="BtnAdd" runat="server" Text="Add To Cart"  CommandName="add" CommandArgument ='<%#Eval("id") %>' />
                                    <asp:Button ID="btnremove" runat="server" Text="Remove From Cart"   CommandName="remove"  />

                                </ItemTemplate>
                            </asp:TemplateField>

                        </Columns>
                    </asp:GridView>
    </div>



in the business logic i give the storedprocedure name, the sp is

create proc procname
as begin
select id, image from tablename
end

id is id of the image, and image is path of the image. i want to bind all of the images from folder using this path.
how can i bind in the page_load event i write

C#
protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        ds = BusinessLogic.DisplayImage();
        GV.DataSource = ds;
        GV.DataBind();

    }


plz any body help me.

thanking you.
Posted

Firstly,
Change this line:
GV.DataSource = ds;

to

GV.DataSource = ds.Tables[0];

After this, you need to map the ImageURL field in datagrid to the image field in your datatable such that it can be picked from there.

Have a look at this[^] and this[^].
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900