Add subheadings to a repeater control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nihaa
    New Member
    • Oct 2008
    • 1

    #1

    Add subheadings to a repeater control

    Hi ,

    i want to add subheadings to a repeater based on the categories.

    I am able to do this on gridview control but not in arepeater.

    this is the code used in girdview
    [code=cpp]
    if (e.Row.RowType == DataControlRowT ype.DataRow)
    {
    DataRowView drv = (DataRowView)e. Row.DataItem;

    if (tmpCategoryNam e != drv["q1option"].ToString())
    {
    tmpCategoryName = drv["q1option"].ToString();

    // Get a reference to the current row's Parent, which is the Gridview (which happens to be a table)
    Table tbl = e.Row.Parent as Table;

    if (tbl != null)
    {
    GridViewRow row = new GridViewRow(-1, -1, DataControlRowT ype.DataRow, DataControlRowS tate.Normal);

    TableCell cell = new TableCell();

    // Span the row across all of the columns in the Gridview
    cell.ColumnSpan = this.GdProd.Col umns.Count;

    cell.Width = Unit.Percentage (100);
    cell.Style.Add( "font-weight", "bold");
    cell.Style.Add( "background-color", "#c0c0c0");
    cell.Style.Add( "color", "white");


    HtmlGenericCont rol span = new HtmlGenericCont rol("span");
    span.InnerHtml = tmpCategoryName ;

    cell.Controls.A dd(span);

    row.Cells.Add(c ell);

    tbl.Rows.AddAt( tbl.Rows.Count - 1, row);
    }
    }
    }
    [/code]
    i tried to add these codes under the onitemdatabound event of repeater but i t shows some errors.

    Can any please help me to rewrite this code so that i can uses it.
    i am new to asp.net ...please i am running out of time...please
    Last edited by Frinavale; Oct 21 '08, 07:33 PM. Reason: added [code] tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    What are the errors you are getting and what have you tried so far?
    Please post any code snippets you think will help to explain your problem and remember to code tags when posting code.

    -Frinny

    Comment

    Working...