HOW TO COLOR CONTROL AT RUN TIME IN ASP.NET
protected void Contorlcolor()
{
try
{
for (int i = 0; i < DataList2.Items.Count; i++)
{
LinkButton lblTypeall = (LinkButton)DataList2.Items[i].FindControl("LinkButton1");
DataList dtl3 = (DataList)DataList2.Items[i].FindControl("DataList3");
if (lblTypeall.Text == ViewState["dl2"].ToString())
{
lblTypeall.ForeColor = System.Drawing.Color.Orange;
da = new SqlDataAdapter("select Stype from subtype where Ptype='" + ViewState["dl2"].ToString() + "'", con);
dt = new DataTable();
da.Fill(dt);
dtl3.DataSource = dt;
dtl3.DataBind();
for (int j = 0; j < dtl3.Items.Count; j++)
{
LinkButton dt33 = (LinkButton)dtl3.Items[j].FindControl("LinkButton1");
if (dt33.Text == ViewState["dl3"].ToString())
{
dt33.ForeColor = System.Drawing.Color.Orange;
}
else
{
dt33.ForeColor = System.Drawing.Color.Green;
}
}
}
else
{
lblTypeall.ForeColor = System.Drawing.Color.Gray;
da = new SqlDataAdapter("select Stype from subtype where Ptype='zzzzzzzz'", con);
dt = new DataTable();
da.Fill(dt);
dtl3.DataSource = dt;
dtl3.DataBind();
}
}
}
catch (Exception)
{
}
}
No comments:
Post a Comment