GridView with bound and unbound columns

Last post 06-11-2007 4:51 AM by Kevin Yu - MSFT. 2 replies.

Sort Posts:

  • GridView with bound and unbound columns

    06-07-2007, 11:46 PM
    • Member
      588 point Member
    • bslim67
    • Member since 05-05-2006, 7:27 AM
    • Posts 485

    Hi all,

    I would like to show a GridView whereby I had certain fields that is bind to database and one field that need to have some logic to get the result, but could not be bind to a database.

    May I know how to create GridView dynamically in this way?

    So far, I had only done it whereby all data is either bind or unbound.

    But I had not done a mixture of this.

    If anyone know of any sample, please let me know.

    Thanks 

     

  • Re: GridView with bound and unbound columns

    06-08-2007, 1:33 AM
    • Contributor
      5,007 point Contributor
    • Liming
    • Member since 01-09-2006, 8:21 PM
    • Mclean, VA
    • Posts 1,017

    Are you asking how to preforme the custom logic for that one field? If so, then you have to hook up the OnRowDataBound to your gridview, upon each row, the method will be called and you can manipulate the data in there. Google "onRowDataBound", you'll find many examples.

    But if you are asking about two-way binding, and you want to update that one "on-the-fly" field back to the datasource, then you'll have to hook up onUpdating to your datasource and update your datasource parameter there.

  • Re: GridView with bound and unbound columns

    06-11-2007, 4:51 AM
    Answer

    Hi,

    Here, you can use <%# Bind("FieldName")") %> or <%# Eval("")%> to do databinding or some logical calculation with <% %>.

    Please check the syntax from the following links:

    http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/templates.aspx
    http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/syntax.aspx

    HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

    Sincerely,
    Kevin Yu
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Mark as Not Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (3 items)