Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Retrieve ASP .Net Datagrid ButtonColumn Text

Posted on 2004-10-08
7
Medium Priority
?
499 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 200 total points
ID: 12257251
Does it work if you convert that column to a template column?

0
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
LVL 6

Assisted Solution

by:margant
margant earned 120 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

722 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