two ways to find a label control in a gridview and set its text property.
Which is the perfered way I perfer the first one, but i'm new to cs.
protected void GridView1_RowCr eated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
// type 1 is more "C" Like
if (((GridViewRow) e.Row).FindCont rol("lbl_One1") != null)
((Label)((GridV iewRow)e.Row).F indControl("lbl _One1")).Text =
"YES!";
// type 2 more VB like
if (((GridViewRow) e.Row).FindCont rol("lbl_One1") != null)
{
Label lbl =
(Label)((GridVi ewRow)e.Row).Fi ndControl("lbl_ Two2");
lbl.Text = "AND Yes!";
}
}
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
Which is the perfered way I perfer the first one, but i'm new to cs.
protected void GridView1_RowCr eated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
// type 1 is more "C" Like
if (((GridViewRow) e.Row).FindCont rol("lbl_One1") != null)
((Label)((GridV iewRow)e.Row).F indControl("lbl _One1")).Text =
"YES!";
// type 2 more VB like
if (((GridViewRow) e.Row).FindCont rol("lbl_One1") != null)
{
Label lbl =
(Label)((GridVi ewRow)e.Row).Fi ndControl("lbl_ Two2");
lbl.Text = "AND Yes!";
}
}
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
Comment