473,666 Members | 2,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wrong data in commandargument after applying rowfilter

Hi

I have a problem gettting the right data in my CommandArgument after I
applyed a rowfilter.

My template column looks somewhat like this:

<asp:TemplateCo lumn HeaderText="Err orID">
<HeaderStyle Width="30%" CssClass="folde rHeader"></HeaderStyle>
<ItemTemplate >
<asp:LinkButt on runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.MyId" ) %>' CommandName="De tails" CommandArgument ='<%#
DataBinder.Eval (Container, "DataItem.MyId" ) %>'
CausesValidatio n="false" ID="lnkbtnDetai ls">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>

First I bind my datagrid to the datatables default view and everything
works fine. When clicking an item, I get the right ID

Then I apply a rowfilter on the dataview and bind again to the
datagrid:

.....
lDv.RowFilter = "SiteId = " & txtSiteID.Text
dtgItems.DataSo urce = lDv
dtgItems.DataBi nd()

Now I get only a few items but when clicking details on, for instance
the second item, in the CommandArgument I get the id from the second
item on the default view and not the second item from the the filtered
view.

Any ideas?

/Liza

Nov 19 '05 #1
2 2777
How are you retrieving this value from your code behind?

I gather you are using the ItemCommand event.

Just check that you are not getting the ItemIndex instead of the ItemId

So in your case, rather use:

Ctype(e.Item.Fi ndControls("lnk btnDetails"), LinkButton).Tex t (this may
be slightly wrong as i'm a c# coder)

than

e.Item.Iteminde x

I also see you are trying to pass this as a COmmandArgument .
Have you checked what the value 'MyId' is placing in your source (through
IE)

HTH

"Liza" <we*******@gmai l.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hi

I have a problem gettting the right data in my CommandArgument after I
applyed a rowfilter.

My template column looks somewhat like this:

<asp:TemplateCo lumn HeaderText="Err orID">
<HeaderStyle Width="30%" CssClass="folde rHeader"></HeaderStyle>
<ItemTemplate >
<asp:LinkButt on runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.MyId" ) %>' CommandName="De tails" CommandArgument ='<%#
DataBinder.Eval (Container, "DataItem.MyId" ) %>'
CausesValidatio n="false" ID="lnkbtnDetai ls">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>

First I bind my datagrid to the datatables default view and everything
works fine. When clicking an item, I get the right ID

Then I apply a rowfilter on the dataview and bind again to the
datagrid:

....
lDv.RowFilter = "SiteId = " & txtSiteID.Text
dtgItems.DataSo urce = lDv
dtgItems.DataBi nd()

Now I get only a few items but when clicking details on, for instance
the second item, in the CommandArgument I get the id from the second
item on the default view and not the second item from the the filtered
view.

Any ideas?

/Liza

Nov 19 '05 #2
wouldn't work with Ctype(e.Item.Fi ndControls("lnk *btnDetails"),
LinkButton).Tex t since I was only using the same id value as text for
demonstration purposes.

Anyways, I sorted it out.

I am using paging on my grid and therefore needed to set datasource -
even on postback. Unfortunately I also did databinding on postback
which caused my event not to work properly. I changed it, so now I set
the grids datasource on all posts but only do the databinding if it's
not postback. Seems to make both my paging and events work :-)

/Liza

Nov 19 '05 #3

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

Similar topics

3
1377
by: OC | last post by:
I have a datatable for which I have bound a DataView. I have three rows in the table, with rowid = '12310104', '12314402', and '12315208'. When I do a dvHdr.RowFilter = '12314402', it returns a count of 1 set to '12310104' rather than what I am looking for. However, if I do, say, dvHdr.RowFilter = '12314403' (non-existent), it results in a count of 0, which is expected. Why can't I filter on what I am expecting?
1
2002
by: VIswanathan S | last post by:
Hi All! How to use Data Repeater in VB.NET? Data Fields are Employee Number Name Photo Date of Joining Salary
0
1555
by: Solomon Shaffer | last post by:
I have a datagrid that I am adding a template column to (containing a couple of linkbuttons) at runtime and am having some difficulty setting the commandargument or the linkbuttons. Does anyone know the syntax to databind the commandargument to the row through code. I am assumning I use the DataBinder.Eval method but I cannot get it going. Below is the code sample. Thanks Solomon public class KnowlagentDataGridTemplate : ITemplate
0
1306
by: Solomon Shaffer | last post by:
This is very interesting - and odd. I have a number of LinkButtons that are created in a custom data grid that I created. The purpose of the LinkButtons is to provide alphabetical filtering functionality on the grid. Therefore, a LinkButton is added for every letter of the alphabet. I also have a numeric filter button and an "All" button that removes the filter. All of the LinkButtons are wired up to the same event called...
2
1083
by: Mark Sandfox | last post by:
dvPOIs.RowFilter = "(County='" & ddlCountyRegion.SelectedItem.Text & "' OR Region='" & ddlCountyRegion.SelectedItem.Text & "')" The objective is to allow the user to chose from one dropdownlist either a county or region, then use rowfilter to display only the rows that have either the county or region that was selected. The current (above) string returns am empty list. Thanks in advance for your help.
0
1280
by: BigAde | last post by:
I'm having problems with the DDL in the datalist below when adding an item. The list binds properly and lists the correct values (up to about 350). The code successfully finds a ddl and loads the value into the sortedlist & the datalist. However, the selected index returned does not (always) match that shown on the web page. The first few items are
1
9908
by: neeraj | last post by:
Hi All Can any give me the code for convert "DataColumn" data type of "DataTable". Even if data table already populated (have data) Actually I am creating one search module which searches the data from "DataView" using "RowFilter" method. Here I m using like operator for searching, its work fine for string but if data type of "Data Column" is Date or Integer then its not working. Now I m decide I will convert data types of all column...
5
1243
by: hime | last post by:
hello all; I am programming a webpage with .NET C# in which I want to display data from database and I am using custom paging * (page size = 4) * I am using imageuttons to navigate (next,prv,first,last) in which I make the decrement or increment but next will only take me to page no. 2, and prv takes me to page no 1. no matter where I am at that point and here is the code for my entire page because I can't figure where the mistake...
2
1422
by: Knoxy | last post by:
Hi guys, I'm using a gridview to do some inline editing. The data binds okay, its goes into edit mode and cancel okay. I'm using my own custom commandName, "save", and it picks this up okay. Don't want to use the built in "update" command. Trouble is when I go to access the form fields (textboxes etc), there isn't any data there (ie text in the textbox), I can access them though, I guess I'm missing an event somewhere. I've stripped...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8638
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.