if(!ispostback)
{
BindDll()
}
void BindDll()
{
SqlConnection mycn;
SqlDataAdapter myda;
DataTable dt;
String strConn;
strConn = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
mycn = new SqlConnection(strConn);
myda = new SqlDataAdapter ("Select * FROM Category", mycn);
dt = new DataTable();
myda.Fill(dt);
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "CategoryName";
DropDownList1.DataValueField ="CategoryId";
DropDownList1.DataBind () ;
for (int i =0;i < DropDownList1.Items.Count ;i++ )
{
DropDownList1.Items[i].Attributes.Add("style", "color:" + dt.Rows[i]["Color"].ToString());
}
}
If the ddl is available in a grid set the property on grid onRowDatabound.
ஏஞ்சல்
என்னை பற்றி
Google reader
Categories
- .Net (9)
- .Net Crystal Report (1)
- .Net GridView (3)
- Articles (5)
- Log File .Net (1)
- Sharepoint (2)
- Sitefinity 3.7 (3)
- SQL (5)
- Technical Question and Ans (3)
- Validation (1)
- XML (2)
Blog Archive
Monday, October 19, 2009
DropdownList Apply Colors for Category
Posted by Meera at 11:09 PM
When hearts listen
angel sing.If you seek an angel with an open heart...
You shall always find loved one