To change the drop down value form the other dropdown selected index change.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((sender) as Control).NamingContainer;
DropDownList dr = (DropDownList)sender;
//DropDownList dr = (DropDownList)GridView1.FindControl("DropDownList1");
DropDownList dropdown2 =(DropDownList)row.FindControl("DropDownList2");
string condition = dr.SelectedValue.ToString();
SelectSubCategory(condition,dropdown2);//a function for filling the child gridview
}
Saturday, November 17, 2007
GridView Changing the row style
If you want to change the style of row or column of a gridview then it can be done in the following way
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
for (int i = 2; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Style.Add("text-align", "right");
//e.Row.Cells[e.Row.Cells.Count-1].Text = "" + e.Row.Cells[i].Text + "";
}
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
for (int i = 2; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Style.Add("text-align", "right");
//e.Row.Cells[e.Row.Cells.Count-1].Text = "" + e.Row.Cells[i].Text + "";
}
}
}
Subscribe to:
Posts (Atom)