Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:12:00+00:00 2026-06-01T20:12:00+00:00

First question how to add custom column to aspxgridview column using looping to get

  • 0

First question how to add custom column to aspxgridview column using looping to get name and value of column.

here is my code behind :

Protected Sub gridSubmission_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridSubmission.Init
        Dim colBaru As GridViewDataTextColumn = New GridViewDataTextColumn()
    For i As Integer = 1 To 6
        colBaru.Caption = i
        colBaru.FieldName = i
        colBaru.UnboundType = DevExpress.Data.UnboundColumnType.Integer
        colBaru.VisibleIndex = gridSubmission.VisibleColumns.Count
        colBaru.PropertiesTextEdit.DisplayFormatString = "c2"
        gridSubmission.Columns.Add(colBaru)
    Next
end sub

which i used to add new column at aspxgridview.
but its getting an error, “An item with the same key has already been added.”

second question, what property which i must use to put that code? I wanted load that code after page.load ! if i put in aspxgridview.init its was loaded before page.load.

and the output it must like this :

1           2          3          4           5           6
row         row        row        row         row         row
row         row        row        row         row         row
row         row        row        row         row         row
row         row        row        row         row         row
row         row        row        row         row         row

help pelase…

thanks before

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:12:01+00:00Added an answer on June 1, 2026 at 8:12 pm

    As far first question goes, you are trying to add same column object again and again into columns, hence you get that error. Try creating column object in the loop – for example:

    Protected Sub gridSubmission_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridSubmission.Init
    
        For i As Integer = 1 To 6
            Dim colBaru As GridViewDataTextColumn = New GridViewDataTextColumn()
            colBaru.Caption = i
            colBaru.FieldName = i
            ... 
    

    As far as second question goes, I am not sure what you are asking here. When you mean before/after page.load, do you mean page_load at server side or page load at client (browser) side? Frankly speaking, grid_init or page_init are the best places to add columns. If you want to add columns in certain event on the page then the best way to do is set some hidden variable on the browser side and use that variable to decide whether to do such initialization or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add custom markers to a mapview. First question : is there
First question here: it is a very short yet fundamental thing in Java that
First question here so hello everyone. The requirement I'm working on is a small
First Question in here :) (AS3) First off, how do I access a variable
my first question is, where do I put this custom extension so that it
it's my first question. I have built a custom component: a RelativeLayout with a
this is my first question here at Stack Overflow. I've been looking for a
I'm trying to create my first custom View subclass GraphView and add it to
This is my first question here so if I'm missing something necessary just reply
it's my first question here.I apologize if i make any mistake or broke forum's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.