?
Solved

How to pass value from gridview to another page

Posted on 2012-08-14
6
Medium Priority
?
383 Views
Last Modified: 2012-08-18
Hi,

I am new and using appended gridview to display data. I need to convert Inv Number column in hyperlink and send its text to another page "~/InvPageAdd.aspx".

Please help

  <asp:HyperLinkField DataTextField="InvNo" HeaderText="Inv Number" />
 
gridview
0
Comment
Question by:Mehram
  • 3
  • 3
6 Comments
 
LVL 61

Expert Comment

by:Julian Hansen
ID: 38295066
Does this help

<asp:HyperLinkField DataNavigateUrlFields="InvNo"
DataNavigateUrlFormatString="InvPageAdd.aspx?inv={0}" DataTextField="InvNo" HeaderText="Inv Number"/>

Open in new window

0
 

Author Comment

by:Mehram
ID: 38295104
showing error on data binding:

error
0
 
LVL 61

Expert Comment

by:Julian Hansen
ID: 38295167
Can you show your code where you have put the hyperlink def in?

Usually you get this error when the type conversion of the parameter you are putting in the link is incorrect.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Mehram
ID: 38295177
<Columns>
    <asp:BoundField DataField="Sno" HeaderText="Serial #" />
    <asp:BoundField DataField="Date" HeaderText="Inv Date" />
    <asp:BoundField DataField="InvNo" HeaderText="Inv Number" />
    <asp:BoundField DataField="Amt" HeaderText="Amount" />
    <asp:BoundField DataField="CoCom" HeaderText="Co Comm"/>
    <asp:BoundField DataField="MkCom" HeaderText="Mk Comm"/>
    <asp:BoundField DataField="NPV" HeaderText="Net Inv Value" ItemStyle-HorizontalAlign="Center">
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    </asp:BoundField>
    <asp:CheckBoxField DataField="FreeStock" HeaderText="Free Stock"/>
    <asp:HyperLinkField DataNavigateUrlFields="InvNo" DataNavigateUrlFormatString="InvPageAdd.aspx?InvNo={8}" Text="Edit" HeaderText="Inv Number"/>
    </Columns>
0
 

Author Comment

by:Mehram
ID: 38295234
Sir,
I did something like this, which is working: please guide me if I can enhance it?


    <Columns>
    <asp:BoundField DataField="Sno" HeaderText="Serial #" />
    <asp:BoundField DataField="Date" HeaderText="Inv Date" />
    <asp:TemplateField>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Invoice #">
    <ItemTemplate>
    <asp:LinkButton ID="lnkname" runat="server"
                Text=<%#Eval("InvNo") %>'
                PostBackUrl='<%#"~/InvPageAdd.aspx?ID="+Eval("InvNo")%>'>
    </asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Amt" HeaderText="Amount" />
    <asp:BoundField DataField="CoCom" HeaderText="Co Comm"/>
    <asp:BoundField DataField="MkCom" HeaderText="Mk Comm"/>
    <asp:BoundField DataField="NPV" HeaderText="Net Inv Value" ItemStyle-HorizontalAlign="Center">
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    </asp:BoundField>
    <asp:CheckBoxField DataField="FreeStock" HeaderText="Free Stock"/>
    </Columns>
0
 
LVL 61

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 38295457
Change this line
<asp:HyperLinkField DataNavigateUrlFields="InvNo" DataNavigateUrlFormatString="InvPageAdd.aspx?InvNo={8}" Text="Edit" HeaderText="Inv Number"/>

Open in new window

to (the {8} => {0} also can try with ~/ infront of url
<asp:HyperLinkField DataNavigateUrlFields="InvNo" DataNavigateUrlFormatString="~/InvPageAdd.aspx?InvNo={0}" Text="Edit" HeaderText="Inv Number"/>

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

580 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