Solved

Retrieve ASP .Net Datagrid ButtonColumn Text

Posted on 2004-10-08
7
490 Views
Last Modified: 2010-08-05
I have created a datagrid with a buttoncolumn and a few boundcolumn.
When I click the buttoncolumn, the values of the row should be retrieved and fill up some textboxes. However, the value of the buttoncolumn is blank, which should be the value retrieved from the database and displayed in the datagrid. Any idea on this? Thanx
0
Comment
Question by:scissorhand
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:Gregsy
ID: 12257140
Is this on Page_load or on Postback

if it on postback are you populating what you need to in the event?

Cheers
Alan
0
 

Author Comment

by:scissorhand
ID: 12257231
i populate the data in the datagrid when the page is first loaded. The data will be repopulated when i click the retrieve button. now i can get every value of the bound column except the button column
0
 
LVL 1

Accepted Solution

by:
Gregsy earned 50 total points
ID: 12257251
Does it work if you convert that column to a template column?

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 6

Assisted Solution

by:margant
margant earned 30 total points
ID: 12259015
Can you show the code?
Are you sure the database hit returns something?
Do you have an button action function OnItemCommand defined in the datagrid? And more importangly - do u rebind your data in that function after you are finished? (last one got me debuggin for some time in the past)


Hope that helps,
-AM
0
 

Author Comment

by:scissorhand
ID: 12274157
i do put OnItemCommand and all the columns value are returned except the buttoncolumn, the code is roughly like this

DgCounter.SelectedIndex = e.Item.ItemIndex ' DgCounter is a datagrid
TbCounterKey.Text = e.Item.Cells(1).Text ' TbCounterKey is a textfield
TbCounterNum.Text = e.Item.Cells(2).Text

I put the code in the itemcommand function
0
 
LVL 6

Expert Comment

by:margant
ID: 12276877
Hm, since I cant see the rest of the code, did you get a chance to review this great article on how to work buttons in Datagrid?

http://aspnet.4guysfromrolla.com/articles/042402-1.aspx
(esp part 2)

I have one more idea of why code may fail :
where do u load ur datagrid? page_load?
make sure its loaded like this, VERY important, otherwise ur e.Item.ItemIndex is reset on every postback
if not ispostback then
  'datagrid databind here
end if

Best of luck,
AM
0
 

Author Comment

by:scissorhand
ID: 12283490
I load the datagrid when I click a retrieve button. But I have tested and find that e.Item.ItemIndex is correct as I can retrieve the value of other columns in the same row. By the way I use template column and put in link button to replace the bound column. It works fine now, thanx to u all.

Margant, if u figure out what happen to the button column, I am interested to know it, thanx.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This video teaches users how to migrate an existing Wordpress website to a new domain.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question