<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ddldesigncontrol.aspx.vb" Inherits="ddldesigncontrol" %>
Datalist Design Page On Dynamic
Imports System.Data
Imports System.Data.SqlClient
Partial Class ddldesigncontrol
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
bindlist()
End If
End Sub
Sub bindlist()
Dim constr = ConfigurationManager.AppSettings("con").ToString()
Dim con As SqlConnection = New SqlConnection(constr)
con.Open()
Dim sql1 = "Select * from tbl1" ' change to ur table name
Dim sql As SqlCommand = New SqlCommand(sql1, con)
Dim ds As DataSet = New DataSet()
Dim da As SqlDataAdapter = New SqlDataAdapter(sql)
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
DataList1.DataSource = ds
DataList1.DataBind()
End If
con.Close()
End Sub
Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
Dim hdn_price As HiddenField = TryCast(e.Item.FindControl("price"), HiddenField)
Dim a_link As HtmlAnchor = TryCast(e.Item.FindControl("anchortag"), HtmlAnchor)
If hdn_price.Value = "ListPrice " Then
a_link.Style.Add("font-size", "10px")
Else
a_link.Style.Add("font-size", "30px")
End If
End Sub
End Class
|