How to create the datalistview by using itemtemplate in asp.net plase any one can help me ..?

Posted by Ravinderreddy under ASP.NET on 7/26/2012 | Points: 10 | Views : 730 | Status : [Member] | Replies : 1
How to create the datalistview by using itemtemplate in asp.net plase any one can help me ..?

Ravindrareddy


Responses

Posted by: Ranjeet_8 on: 7/26/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
    <asp:DataList ID="DataList1" runat="server"> 

<ItemTemplate>
<table><tr><td><asp:Label ID="Label1" runat="server" Text='<%#Eval("Column_Name")%>'></asp:Label></td></tr>
<tr><td> <asp:Label ID="Label2" runat="server" Text='<%#Eval("Column_Name")%>'></asp:Label></td></tr>
</table>
</ItemTemplate>
</asp:DataList>


public void BindData()

{
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from Table_Name", con);
DataTable ds = new DataTable();
da.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
catch (Exception ex)
{
Label1.Text = ex.Message.ToString();
}
finally
{
con.Close();

}}


Ravinderreddy, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response