This is a migrated thread and some comments may be shown as answers.

several ItemTemplate in GridTemplateColumn

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohammad sadegh
Top achievements
Rank 1
Mohammad sadegh asked on 22 Jul 2011, 09:14 PM
hi

I have a table with only one TemplateColumn.
but this column must show different figures by TYPE column of dataset. for example, if TYPE=1 then show user picture, Name and Family
and if TYPE=2 then show some other columns with a special figure.
that means i want make a table with Facebook wall stye that in every rows shows some data with true Template.
witch solution do you refer?

best regards
Mohammad

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Jul 2011, 07:19 AM
Hello Mohammed,

You can access the controls in ItemTemplate and set the visibility of the column accordingly.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridDataItem)
   {
            GridDataItem item = (GridDataItem)e.Item;
            Label type1= (Label)item.FindControl("lbl");
            if (type1.Text == "1")
            {
                RadGrid1.MasterTableView.GetColumn("Name").Visible = true;
            }
             else if (type1.Text == "2")
            {
                RadGrid1.MasterTableView.GetColumn("Columns").Visible = false;
            }
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Mohammad sadegh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or