Avatar of Brian
Brian
Flag for United States of America asked on

GridView Formatting

Hello Experts,

I would like to include two images that represent "Modify" and "Delete" for each row displayed in the GridView. So when the user mouses over the image it displays the unique_id and when clicked will go to another page that will retrieve the selected data.

Is it possible to add an image for a GridView Row?

                <asp:GridView ID="gv_CourseSchedules" runat="server" AutoGenerateColumns="False"
                    GridLines="None" Width="600px">
                    <AlternatingRowStyle BackColor="#D5E7C0" CssClass="GridViewInfo" />
                    <Columns>
                        <asp:BoundField DataField="ghaco_name" ItemStyle-CssClass="GridViewInfo">
                        <HeaderStyle HorizontalAlign="Left" />

<ItemStyle CssClass="GridViewInfo"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="hmi_name" ItemStyle-CssClass="GridViewInfo">
                        <HeaderStyle HorizontalAlign="Left" />

<ItemStyle CssClass="GridViewInfo"></ItemStyle>
                        </asp:BoundField>
                        <asp:BoundField DataField="csch_startdate" DataFormatString="{0:D}" ItemStyle-CssClass="GridViewInfo">
                        <HeaderStyle HorizontalAlign="Left" />

<ItemStyle CssClass="GridViewInfo"></ItemStyle>
                        </asp:BoundField>
                        <asp:HyperLinkField DataNavigateUrlFields="csch_id"
                            DataNavigateUrlFormatString="schedule_update.aspx?csch_id={0}"
                            DataTextField="csch_id" DataTextFormatString="Modify" />
                        <asp:HyperLinkField DataNavigateUrlFields="csch_id"
                            DataNavigateUrlFormatString="schedule_delete.aspx?csch_id={0}"
                            DataTextField="csch_id" DataTextFormatString="Delete" />
                    </Columns>
                </asp:GridView>

Thanks in advance!!!
ASP.NET.NET Programming

Avatar of undefined
Last Comment
Brian

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
madgino

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Anurag Thakur

add item template to the gridview
and add an image to it
on row data bound event of gridview add in in the desired parameters (example id of the item to be edited or deleted) and the screen or logic to be called when the image is clicked

the following link provides way to use button field
http://www.asp.net/data-access/tutorials/adding-and-responding-to-buttons-to-a-gridview-cs
Brian

ASKER
@ madgino,

Thanks for helping me with this post. However, I have tried the following that you have mentioned above but the problem that I have with using that method is how/where do I add a link like I have below?

Below is what I currenlty use now which works fine except I want it to look prettier with icons :)

UPDATE:
<asp:HyperLinkField DataNavigateUrlFields="csch_id"
    DataNavigateUrlFormatString="schedule_update.aspx?csch_id={0}"
    DataTextField="csch_id" DataTextFormatString="Modify" />

DELETE:
 <asp:HyperLinkField DataNavigateUrlFields="csch_id"
    DataNavigateUrlFormatString="schedule_delete.aspx?csch_id={0}"
    DataTextField="csch_id" DataTextFormatString="Delete" />
Anurag Thakur

try using an imageurl as it will give more control in making your view pretty
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Brian

ASKER
@ragi0017

Not sure what you mean.
Anurag Thakur

there is a image URL property in hyper link field in asp.net
Brian

ASKER
There is ONLY an ImageURL for the HeadImageURL proptery within the HyperLink filed. I need it to display for every row returned.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Anurag Thakur

Can you please try to use the solution suggested by madgino because there you will be using an item template which contains image buttons and those image buttons can be customized to show pictures and the corresponding actions can be taken through programming
Brian

ASKER
@madgino / ragi0017,

ragi0017, I see madgino's post and I understand what he is referring to BUT I need to link to another page passing the "ID" value to that page. I don't see an option for adding a link using an ImageButton Control.

Am I missing something?
SOLUTION
Anurag Thakur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Brian

ASKER
Thank you both!!!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes