i am creating an image gallery (images stored in Images folder,path saved in db) in the gridview
Each imagename is saved in dbwith and uinque id and the columnname : storyid.
can anyone tell me how to bind the indiviudal images "like" count in the lblcount
<form id="form1" runat="server"> <asp:ScriptManager runat="server" ID="SM1"> asp:ScriptManager> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Font-Names="Arial" OnRowCommand="GridView1_RowCommand1"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional"> <ContentTemplate> <asp:Button runat="server" ID="IncreaseButton" Text="Like" CommandName="Increase" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" /> <asp:Label runat="server" ID="lblCount">asp:Label> <div style="display: none;"> <asp:Label Text="<%#Bind('StoryId')%>" ID="lblStoryid" runat="server">asp:Label> div> ContentTemplate> asp:UpdatePanel> ItemTemplate> asp:TemplateField> <asp:ImageField DataImageUrlField="FilePath" ControlStyle-Width="100" ControlStyle-Height="100" HeaderText="Preview Image"> <ControlStyle Height="100px" Width="100px">ControlStyle> asp:ImageField> <asp:TemplateField> <HeaderTemplate> <asp:Label Text="Description" runat="server" Visible="False">asp:Label> HeaderTemplate> <ItemTemplate> <asp:Label Text="<%#Bind('Description')%>" ID="lblImageid" runat="server">asp:Label> ItemTemplate> <EditItemTemplate> EditItemTemplate> asp:TemplateField> Columns> asp:GridView> div> form>public partial class Gallery : System.Web.UI.Page
{
private void bindimage() { DataTable dt = new DataTable(); String strConnString = System.Configuration.ConfigurationManager. ConnectionStrings["dbconnection"].ConnectionString; string strQuery = "select * from story"; SqlCommand cmd = new SqlCommand(strQuery); SqlConnection con = new SqlConnection(strConnString); SqlDataAdapter sda = new SqlDataAdapter(); cmd.CommandType = CommandType.Text; cmd.Connection = con; try { con.Open(); sda.SelectCommand = cmd; sda.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } finally { con.Close(); sda.Dispose(); con.Dispose(); } }
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaganathan BantheswaranPosted Dec 8, 2013, 11:34 PM