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

Putting certain rows in Italics

3 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed Bassin
Top achievements
Rank 1
Ed Bassin asked on 25 Jul 2008, 06:31 PM
I have an SQL database which has an "optional" column.  I want the rows of my grid to be in italics if that row is optional.

Here is what the grid might look like after this is done:

Grouper | Field | Length
---------------------------
Age           x        3
Sex            y        1
Provider    z        12
Name        b         12

If the 'Provider' row is optional, it is put in italics, like shown above.

How do I create this effect?

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jul 2008, 04:40 AM
Hi,

Try the following code snippet to achieve the desired scenario.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strtxt = item["Grouper"].Text.ToString(); 
            if (strtxt=="Provider") 
            { 
               item["Grouper"].Font.Italic = true
            } 
        } 
   } 


Thanks
Shinu.
0
Ed Bassin
Top achievements
Rank 1
answered on 28 Jul 2008, 01:26 PM
Thanks Shinu,

how do I access a piece of data like 'required' when required is not a column in the grid.  Is there some way to make an 'invisible' column which just stores the needed data?
0
Princy
Top achievements
Rank 2
answered on 29 Jul 2008, 04:19 AM
Hello Ed,

You can access a column which is not part of the Grid but a column in the DataBase by using the DataKeyNames property of the Grid as shown in the code below.

aspx:
<MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="required" > 
</MasterTableView> 

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string name = item.GetDataKeyValue("required").ToString(); 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Ed Bassin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ed Bassin
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or