imagefield clickable in a gridview - asp.net

i have this imagefield in a gridview
<asp:ImageField HeaderText="Image" DataImageUrlField="Image_Path" ControlStyle-Width="50" ControlStyle-Height="50"/>
the image_path is a column name from the database that retuns the image link
i need to make this field clickable so once i click on it i need to popup a form just like this field:
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" CommandName="Select" onClick="popup_click" class="table-actions-button ic-table-edit" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
i tried to put an image button instead of an image field but i'm always getting submit query instead of the image...
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" DataImageUrlFormatString="Image_Path" ControlStyle-Width="50" ControlStyle-Height="50"/>
</ItemTemplate>
does anyone know how can i fix this?

Related

Image in GridView ASP

I have a grid view in which in one column I want to display images. I have image URL stored in the database.I want the the gridview to dynamically bind the ImageField with the url from the database.
Try this.
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="ProductImage" runat="server" ImageUrl='<%# Eval("ProductImagePath") %>'/>
</ItemTemplate>
</asp:TemplateField>
Or this
<asp:ImageField HeaderText="Image" DataImageUrlField="ProductImagePath"/>

How to change checkbox value in gridview

I have one gridview. In this gridview one column itemtemplate has check box. I want to change the text of checkbox during check or unchecking the check box.
Can any on help the code.
Thanks In advance
Eshwer
you should be use TemplateField for display your checkbox:
<asp:TemplateField HeaderText="headerText">
<ItemTemplate>
// your image or text for display checked or not
<asp:Label ID="Label6" runat="server" Text='<%# Eval("isView")=="True"?"IS CHECKED":"NOT CHECKED" %>'></asp:Label>
</ItemTemplate>
<EditTemplate>
<asp:CheckBox DataField="isView" runat="server" />
</EditTemplate>
</asp:TemplateField>

open a new webpage when a hyperlink is clicked, and where to set the page in VS

I have asp.net, and a webpage here:
<asp:GridView ID="BalanceCheckDataGridView" runat="server" AutoGenerateColumns="false" OnRowDataBound = "DataGridViewTotalSum" >
<Columns>
<asp:TemplateField HeaderText="Company" ItemStyle-Width="20%" >
<ItemTemplate>
<asp:HyperLink Text='<%# (Eval("Company"))%>' ID="HyperLink1" Target="_blank" runat="server"
NavigateUrl=WHAT SHOULD I PUT HERE IF I WANT TO NAVIGATE TO ANOTHER WEBPAGE IN THE SAME SOLUTION
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="30%" DataField="Balance" HeaderText="Balance" />
</Columns>
</asp:GridView>
So column“Company” is a hyperlink. when people click on it, i want to show in another webpage or add a gridview of the details information about that company. So, I need to pass the company name to it too.
How should I set the link in the hyperlink field? so that it can navigates to a webpage inside the solution?
Thanks.

Hyperlink control (inside TemplateField tags) is not acting like an anchor tag?

I have this murkup somewhere in my gridview. The gridview is showing the data for that column, but it's not showing up like an anchor tag, i.e. no underlining and not possible to click it (Just like plain-tex).
<asp:TemplateField HeaderText="Status" Visible="True"> <ItemTemplate>
<asp:HyperLink ID="statusHpLink" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Status") %>' /> </ItemTemplate>
<ItemStyle CssClass="itemstyle" />
</asp:TemplateField>
Thanks for helping
YOu need to set the NavigateUrl attribute in your markup.
<asp:HyperLink runat="server" ID="link" Text="Click Me"
NavigateUrl="http://stackoverflow.com"/>

Gridview : Hyperlink and description in the same column cell

Apologies for the newbie question. My client wishes me to make a small change to the gridview on his http://www.flogitdonegal.com/SearchPage.aspx page.
Note the way the Title column is a hyperlink to view more information. This comes from a 'BriefDescription' field in the database.
How can I add 250 chars from the 'FullDescription' underneath the Title in the same cell, but I dont want it be a hyperlink.
Essentially it will be 2 fields coming into the same column.
Thanks in advance for all help.
John
If this is using a GridView you are most likely using a TemplateField as it is to display the HyperLink.
Within the ItemTemplate of the TemplateField you can specify an additional Label underneath using something as follows:
<asp:Label runat="server" id="FullDescLabel" Text='<%# DataBinder.Eval(Container.DataItem, "FullDescription") %>' />
You need to use the TemplateField and here is a tutorial that explains some of the other fields that GridView offers as well.
<asp:GridView ID="gvwCompounds" runat="server" DataSourceID="objItemsFromYourDB">
<Columns>
....
<asp:TemplateField>
<ItemTemplate HeaderText="Title">
<asp:HyperLink runat="server" ID="Hperlink1" NavigateUrl='<%# Eval("BriefDescriptionUrl") %>' Text='<%# Eval("BriefDescription") %>' />
<br />
<asp:Label runat="server" ID="Label1" Text='<%# Eval("FullDescription") %>' />
</ItemTemplate>
</asp:TemplateField>
....
</Columns>
</asp:GridView>

Resources