TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
varun sharma
NA
150
2.7k
How to make DataList clickable and open with unique id
Feb 11 2018 1:22 AM
<asp:DataList ID="dlCustomers" runat="server" RepeatColumns="4" CellSpacing="0" RepeatLayout="Table">
<ItemTemplate>
<table class="table">
<tr>
<th colspan="2">
<b>
<%# Eval("Name") %></b>
</th>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblId" Text='<%# Eval("id") %>' runat="server" />,
<%# Eval("ContentType") %>
</td>
</tr>
<tr>
<td>
Image:
</td>
<td>
<asp:ImageButton ID="imgImage" runat="server" ImageUrl='<%# "data:jpg;base64," + Convert.ToBase64String((byte[])Eval("Data")) %>'
Height="75px" Width="75px"/>
</td>
</tr>
<tr>
<td colspan="2">
Name:
<%# Eval("Name")%>
</td>
</tr>
<tr>
<td colspan="2">
ContentType:
<%# Eval("ContentType")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = this.GetData();
dlCustomers.DataSource = dt;
dlCustomers.DataBind();
}
}
private DataTable GetData()
{
string conString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("SELECT id, Name, ContentType,Data from tblFiles "))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
}
Reply
Answers (
2
)
How to select & store column values from MS SQL DB
paytm integration