473,405 Members | 2,167 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,405 software developers and data experts.

Gridview - Paging - Linkbutton - Problem

Ram
Hi All,

I am binding a GridView control using object data source. I have
included a linkbutton with in the gridview and using its commandname
property , I am passing few values( id and name fields). I have set the
AllowPaging property to true and Pagesize property to 5.

While running the application, in the first page of the gridview
things are working fine. ie. On licking the linkbutton values are
passed correctly to the target page . But in the second page , values
are not passed correctly. It takes the values of the corresponding row
from the first page of the grid view and hence wrong values are passed
to the target page.

Please help me in solving this problem.

Thanks in advance.
Regards,
S.Ramalingam.

Jun 19 '06 #1
4 6843
On 18 Jun 2006 22:58:06 -0700, Ram wrote:
Please help me in solving this problem.


Without seeing your source code, my only guess is that you're using the
wring property to index into your recordset.
Jun 19 '06 #2
Ram
Erik Funkenbusch wrote:
On 18 Jun 2006 22:58:06 -0700, Ram wrote:
Please help me in solving this problem.


Without seeing your source code, my only guess is that you're using the
wring property to index into your recordset.


Hi Erik,

Thanks for replying. Here is the source code.

sample.aspx
------------------
<asp:GridView id="GV_bookings" DataSourceID="Obj_bookings"
runat="server" allowpaging="True" PageSize="5"
autogeneratecolumns="False" >
<Columns>
<asp:TemplateField HeaderText="Booking Number" >
<ItemTemplate>
<asp:LinkButton ID="lbBookingNo"
runat="server" OnClick="LinkButton_OnClick"
CommandName='<%#
"bookingDetails.aspx?bookingId=" + Eval("bookingId")%>' Text='<%#
Eval("bookingNo") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField DataField="employeeName"
HeaderText="Employee Name" />
<asp:BoundField DataField="consultantName"
HeaderText="Consultant Name" />
</Columns>
</asp:gridview>

<asp:ObjectDataSource ID="Obj_bookings" runat="server"
SelectMethod="getAllBookings"
TypeName="Bookings"></asp:ObjectDataSource>

sample.aspx.cs
----------------------

protected void LinkButton_OnClick(object sender, EventArgs args)
{
LinkButton lb = (LinkButton)sender;
Server.Transfer(lb.CommandName);
}

I hope u understand this simple code. I haven't written anything more
than this. On clicking the booking number (link button) in the grid
view , the id and bookingno are passed to the "bookingDetails.aspx"
page. This is working fine for the first five records( ie for the first
page of the gridview). But in the second page if I click the link
button , say in the first row , the values in the first row of the
first page is passed to the next page.ie the actual values are not
passed.

Pls revert back with some good suggestions.
Regards,
S.Ramalingam

Jun 19 '06 #3
On 19 Jun 2006 02:08:51 -0700, Ram wrote:
I hope u understand this simple code. I haven't written anything more
than this. On clicking the booking number (link button) in the grid
view , the id and bookingno are passed to the "bookingDetails.aspx"
page. This is working fine for the first five records( ie for the first
page of the gridview). But in the second page if I click the link
button , say in the first row , the values in the first row of the
first page is passed to the next page.ie the actual values are not
passed.


Honestly, I'm not even sure why your code is working at all.

You should be doing this:

<asp:LinkButton ...
CommandName='bookingDetails.aspx?bookingId=<%#Eval ("bookingNo") %>' ... />

This probably isn't the right thing to do, though. You should probably use
the HyperLinkField instead, this allows you to more easily bind the value
as well as the text. Set the DataNavigateField to bookingNo, and the
DataNavigateUrlFormatString to "bookingDetails.aspx?bookingId={0}"
Jun 19 '06 #4
Ram
Hi Erik,

Thanks again for u'r suggestion. In case of hyperlink fields the
values are displayed in the address bar. That's why I used link
buttons. But the thing is , the code works well when I am using it in
separate pages . But it doesn't seem to work when I am using nested
master pages.The "LinkButton_onClick" event is wriitten in a separate
class file since in many screens of my application I am using the
gridview with link buttons.
Thanks and Regards,
S.Ramalingam

Erik Funkenbusch wrote:
On 19 Jun 2006 02:08:51 -0700, Ram wrote:
I hope u understand this simple code. I haven't written anything more
than this. On clicking the booking number (link button) in the grid
view , the id and bookingno are passed to the "bookingDetails.aspx"
page. This is working fine for the first five records( ie for the first
page of the gridview). But in the second page if I click the link
button , say in the first row , the values in the first row of the
first page is passed to the next page.ie the actual values are not
passed.


Honestly, I'm not even sure why your code is working at all.

You should be doing this:

<asp:LinkButton ...
CommandName='bookingDetails.aspx?bookingId=<%#Eval ("bookingNo") %>' ... />

This probably isn't the right thing to do, though. You should probably use
the HyperLinkField instead, this allows you to more easily bind the value
as well as the text. Set the DataNavigateField to bookingNo, and the
DataNavigateUrlFormatString to "bookingDetails.aspx?bookingId={0}"


Jun 20 '06 #5

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

Similar topics

2
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
0
by: Mike P | last post by:
I am trying to edit a gridview while using paging, but whenever I try to edit a row on a page other than page 1, I get an error. Here is my gridview and my code : <asp:GridView ID="GridView1"...
0
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control...
3
by: | last post by:
Hi all, I am trying to have a linkbutton control with the commandname property set. However, when I invoke it, the CommandArgument property ends up coming to be blank. However, if I click on the...
1
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages,...
4
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such...
2
by: dixonjm | last post by:
I have quite a complicated problem with the above. I will do my best to explain, although I have a word doc (too large to attach here 149KB) with the problem explained full with screen shots if any...
4
by: Jeff | last post by:
Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET GridView with paging and sorting. One of the columns of this Gridview is a template column (LinkButton). The data being...
0
KalariaNitya
by: KalariaNitya | last post by:
Hello, could anybody help me? i have gridview, inside gridview i have one Update button & textbox update button update the quantity entered in textbox. i want to update the quantity on textbox on...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...
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
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.