GridViewAdapter Row.Attributes and Row.Styles

Last post 11-01-2006 1:17 PM by adk. 3 replies.

Sort Posts:

  • GridViewAdapter Row.Attributes and Row.Styles

    10-31-2006, 11:45 AM
    • Member
      30 point Member
    • adk
    • Member since 10-31-2006, 12:30 PM
    • Posts 6

    I noticed that the GridViewAdapter does not render the Row.Attributes and Row.Styles.

    Here  is the code I used to get it working. Hope someone finds it helpful.

    Inside the  WriteRows method, add the following code after the  

    foreach (GridViewRow row in rows)
      and before the  
    writer.Write(HtmlTextWriter.TagRightChar);
     

     

     if (row.Attributes.Count > 0)
    {
    foreach (string key in row.Attributes.Keys)
    {
    writer.WriteAttribute(key, row.Attributes[key]);
    }
    }
    if (row.Style.Count > 0)
    {
    foreach (string key in row.Style.Keys)
    {
    writer.WriteStyleAttribute(key, row.Style[key]);
    }
    }
     

  • Re: GridViewAdapter Row.Attributes and Row.Styles

    10-31-2006, 7:01 PM
    • Member
      30 point Member
    • adk
    • Member since 10-31-2006, 12:30 PM
    • Posts 6

    Hey guys,

    Please ignore the second if block, it is unneccessary an incorrect.

    It appears that the style attribute generated from Row.Styles is already in the row.Attributes collection.

     

    I apologize for posting untested code. Lesson learned.

     
    p.s. Can anyone point me to the forum FAQ? Alternately, can you tell me if it is possible to edit a post?(I'd like to correct the code in the original post)

     
    Thanks,

    Andrej 

     

     

  • Re: GridViewAdapter Row.Attributes and Row.Styles

    11-01-2006, 11:02 AM
    • Contributor
      3,298 point Contributor
    • Russ Helfand
    • Member since 09-14-2005, 6:22 PM
    • Groovybits.com
    • Posts 741

    Hi Andre,

    Please don't worry too much about needing to correct your initial posting.  Lots of people (including yours truly) do likewise from time to time.  I don't think folks really mind if you add notes to refine earlier posts.

    That said, if you want to edit your post you may be able to seek help from this forum's moderator: Alister Jones (username:SomeNewKid).  Or, you can post requests of that sort to the forum dedicated to site feedback, http://forums.asp.net/188/ShowForum.aspx.  Let me reiterate, however, that you really don't need to try to edit your post (in my opinion) because no one is going to mind your addendum instructions.

    Thanks for your contribution.

    Russ Helfand
    Groovybits.com
  • Re: GridViewAdapter Row.Attributes and Row.Styles

    11-01-2006, 1:17 PM
    • Member
      30 point Member
    • adk
    • Member since 10-31-2006, 12:30 PM
    • Posts 6

    Thanks Russ,

     Appreciate the information. I will leave the initial post as it is.  

    Andrej 

     

Page 1 of 1 (4 items)