What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 48128 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > How bind the IMAGE BTTON IN ASP.NET ...
K011gusain89

How bind the IMAGE BTTON IN ASP.NET

 Code Snippet posted by: K011gusain89 | Posted on: 10/21/2012 | Category: C# Codes | Views: 323 | Status: [Member] | Points: 40 | Alert Moderator   


asp code

<asp:DataList ID="DataList1" runat="server" BorderStyle="Inset">

<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510"/><HeaderStyle BackColor="#A55129" Font-Bold="True" Font-Size="Large" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<ItemTemplate>
<div>
<asp:ImageButton ID="Image1" ImageUrl='<%# Bind("like_pic", "~/upload/{0}") %>' runat="server" CommandArgument='<%#Eval("id")%>' CommandName="like"/>
</div>
</ItemTemplate>
</asp:DataList>

C#

SqlConnection con = new SqlConnection("Server=Servername-PC;Database=databasename;integrated security=true");
int count;
int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack != true)
{
bindData();

}
}

void bindData()
{
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = con;
cmd1.CommandText = "select * from Tb_name ";
cmd1.Connection.Open();
SqlDataReader rdr1 = cmd1.ExecuteReader();
DataList1.DataSource = rdr1;
cmd1.Connection.Close();
}
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 11:49:39 AM