GridView control in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahling
    New Member
    • Jan 2009
    • 7

    GridView control in asp.net

    Hi,

    I have a question to ask regarding the gridview control in visual basic 2008.

    How to bound data to the gridview control?
    I tried to link the gridview to the sqlsourcedata but after linking, I realised that the words in the rows and columns (not including the header) showed me 'abc' instead of 'databound'. This abc means that I did not link my gridview to the sqlsourcedata properly? I don't know...

    And, how to ensure that when I update a blog entry, the blog entry data would be displayed in the specified gridview column?

    P/S: I'm doing a blogger using asp.net which allows user to update blog entries etc.

    Please help, this is urgent.
    Thanks.
  • ahling
    New Member
    • Jan 2009
    • 7

    #2
    Ohya, this updating of data into the gridview doesnt mean I physically add information into the specified column in the gridview. I suppose you all know how a blog works? When the user typed in the blog entry into the textfield, when they click update, it will automatically update the data into the gridview. That's what I want =)

    Comment

    • shweta123
      Recognized Expert Contributor
      • Nov 2006
      • 692

      #3
      Hi,

      You can write the following code in order to bind the database table to the gridview:

      Code:
             //give here the name of data source object in order to 
      //bind to gridview
        
                        //Because we have set the datasource property make  'AutoGenerateColumns' property false 
                        gridview1.AutoGenerateColumns = false
                       gridview1.Datasource = sqldatasource
                       gridview1.DataBind()

      Hope this is what you want.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by ahling
        Hi,
        This abc means that I did not link my gridview to the sqlsourcedata properly? I don't know...
        "ABC" must be a column name or property name that your data source contains.
        Since the GridView is auto-generating the columns for you based on your data source you are seeing ABC as a header.

        Comment

        • ahling
          New Member
          • Jan 2009
          • 7

          #5
          Originally posted by shweta123
          Hi,

          You can write the following code in order to bind the database table to the gridview:

          Code:
                 //give here the name of data source object in order to 
          //bind to gridview
            
                            //Because we have set the datasource property make  'AutoGenerateColumns' property false 
                            gridview1.AutoGenerateColumns = false
                           gridview1.Datasource = sqldatasource
                           gridview1.DataBind()

          Hope this is what you want.
          Hmm thanks.
          But it is not necessary we write codes to bind the database to the gridview?
          Can we just link the gridview to the database?

          And, my gridview doesn't appear when I view it in browser... How to solve it?

          Thanks.

          Comment

          • ahling
            New Member
            • Jan 2009
            • 7

            #6
            Originally posted by Frinavale
            "ABC" must be a column name or property name that your data source contains.
            Since the GridView is auto-generating the columns for you based on your data source you are seeing ABC as a header.
            Oh, I see. Thanks :)

            Comment

            • shweta123
              Recognized Expert Contributor
              • Nov 2006
              • 692

              #7
              Hi,

              Please refer the following link regarding the error that you are getting :
              Grid view control in ASP .Net 2.0

              Comment

              Working...