473,395 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

LinkButton CommandArgument bound property loses value on postback

Hello all,

My basic problem is that my LinkButton does not support a data bound
CommandArgument property under certain cases. The intent is to filter my
datagrid based on a specific row's value, so one query might return players
from multiple schools; clicking on a player row's school linkbutton will
filter the previous query to that school.

The linkbuttons bind properly (including the commandArgument) when the
templatecolumn is early in the columns collection. Later in the collection,
given a certain state, I remove two of the columns from the collection,
because data is not available to populate them. Unfortunately, if I put the
tempate column that contains the Linkbutton with the bound CommandArgument
property after the deleted columns, the command argument always shows up as
an empty string, "".

I'm stumped. I am getting ready to just databind the DataTable and query
the table based on the row index - but is resource intensive, and clunky,
especially on higher data pages.

Any suggestions?

Ben Joldersma
Sr. Software Developer,
Citadel Media Inc.
Nov 18 '05 #1
2 6479
I said databind the DataTable in the last paragraph - I mean to say store the
DataTable in the ViewState.

Also, if I debug the application, immediately after the databind occurs,
examination of the DataGrid1.Items[0].Cells[ IndexOfLinkButtonCell
].Controls[ IndexToLinkButtonControl ].CommandArgument reveals the correct
value. So something is being lost between this point and when I receive
control in the DataGrid_ItemCommand event.

--ben
Nov 18 '05 #2
Success.

I figured out a solution. The reason I wanted to remove the invalid columns
was because my application would raise an exception when it was trying to
databind the BoundColumns (the error was that the column reference didn't
exist in the DataTable.) I had tried previously to just set the invalid
columns visible propety to false, but the error would still raise. So now,
for the bound columns, I set the DataField property to null, then set the
visible property to false, instead of removing the columns entirely. Now the
CommandArgument property on the later columns is preserved correctly!

--ben
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the...
5
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the...
3
by: CodeRazor | last post by:
I am creating an aspx page using C# and would like to be able to dynamically create linkbuttons that all run the same fuction on the click event. However, I would like the function to accept a...
1
by: Sandy | last post by:
I have a repeater which shows Group names. (Skip this part if you want rather irrelevant) The groups are ordered and formatted: Parent ---Child ------Grand Child (okay start reading again...
2
by: News | last post by:
Hi, I need help with datalist and linkbutton. I need a LinkButton to display in datalist if datafield "is_measure_customchecklist" in a db table set to true. Here is the code (in parts): ...
1
by: Bazza Formez | last post by:
Hi, The intended functionality is as follows : I want the user to be able to click on the LinkButton for an individual row in a datagrid, server side sub grabs id for item selected, stores in...
4
by: News | last post by:
Hi, I need help with datalist and linkbutton. I need a LinkButton to be visible in datalist only on the condition when datafield "is_measure_customchecklist" in a db table set to true. Here...
2
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous...
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.