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

Group FormatString setting lost on databind

4 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 12 Mar 2009, 01:25 AM
When I DataBind or Rebind by RadGraid which has a groupbyexpression.  The format gets lost.  I have to do a full postback to see the group fiends format correctly.

<GroupByExpressions>
                                                                                            <telerik:GridGroupByExpression>
                                                                                                <SelectFields>
                                                                                                    <telerik:GridGroupByField FieldAlias="&nbsp;" FieldName="ActionDay" FormatString="{0:M/d}" HeaderValueSeparator=""
                                                                                                        HeaderText="">
                                                                                                    </telerik:GridGroupByField>
                                                                                                </SelectFields>
                                                                                                <GroupByFields>
                                                                                                    <telerik:GridGroupByField FieldAlias="" SortOrder="Descending" FieldName="ActionDay"
                                                                                                        FormatString="{0:M/d}" HeaderText=""></telerik:GridGroupByField>
                                                                                                </GroupByFields>
                                                                                            </telerik:GridGroupByExpression>
                                                                                        </GroupByExpressions>


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Mar 2009, 04:40 AM
Hi Patrick,

Are you binding the Grid using AdvanceDataBinding techniques? If not consider binding the Grid in the NeedDataSource event. If this doesnot help consider sending your code behind.

Thanks
Shinu
0
Patrick
Top achievements
Rank 1
answered on 12 Mar 2009, 12:04 PM
Hi Shinu - No, I am actually not using the advanced databinding.  I don't believe I need to in this case since my problem is a very basic one.

I have a grid that lists notes.  I have a formview under the grid to insert a note, using a sqldatasource.  In the datasource_inserted event (code behind), I rebind() the RadGrid.

All the data is populated correctly, except the group header.  The group header loses its format string.  I have the date when the note is posted in the header and formated to show only the month/day like "3/12"  However the full date string is shown instead when I fire the rebind() or databind() command.




0
Patrick
Top achievements
Rank 1
answered on 12 Mar 2009, 01:00 PM
I removed the FieldAlias="&nbsp;" and its now working okay.  How can I remove the fieldname in the group header from code behind?
0
Princy
Top achievements
Rank 2
answered on 13 Mar 2009, 07:09 AM
Hello Patrick,

Try the following code snippet for removing the fieldname from the group header.

CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
{  
    if (e.Item is GridGroupHeaderItem)  
    {  
        GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;  
        DataRowView groupDataRow = (DataRowView)e.Item.DataItem;  
        item.DataCell.Text = item.DataCell.Text.Split(':')[1].ToString();  
    }  

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