943,724 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 3662
  • ASP.NET RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Apr 22nd, 2009
0

Re: how should i do it?

Hi,

In the code shown below if you want to pass values to next page containing primary key of the record then change the code to
ASP.NET Syntax (Toggle Plain Text)
  1. <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "ServerID")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "ServerID")+ ">Delete</a>" %>'></asp:Label>
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Apr 22nd, 2009
0

Re: how should i do it?

hi,

I still get errors do I need something in the server side code?:

ASP.NET Syntax (Toggle Plain Text)
  1. Compiler Error Message: CS0103: The name 'ch' does not exist in the current context
  2.  
  3. Source Error:
  4.  
  5.  
  6.  
  7. Line 39: <asp:TemplateField HeaderText="Action">
  8. Line 40: <ItemTemplate>
  9. Line 41: <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
  10. Line 42: </ItemTemplate>
  11. Line 43: <ItemStyle HorizontalAlign="Center" />

Code is as follows:

ASP.NET Syntax (Toggle Plain Text)
  1. <asp:GridView ID="ListOfServers" runat="server" AllowPaging="True"
  2. AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid"
  3. BorderWidth="2px" CaptionAlign="Bottom" CellPadding="4" DataKeyNames="ServerID"
  4. DataSourceID="SqlDataSource1" Font-Bold="True" Font-Names="Cordia New"
  5. Font-Size="Medium" ForeColor="#333333" HorizontalAlign="Center"
  6. ToolTip="This table contains the current list of monitored servers."
  7. Width="95%">
  8. <RowStyle BackColor="#EFF3FB" />
  9. <Columns>
  10. <asp:CommandField ShowSelectButton="True" />
  11. <asp:BoundField DataField="ServerID" HeaderText="ServerID"
  12. InsertVisible="False" ReadOnly="True" SortExpression="ServerID" />
  13. <asp:BoundField DataField="HostName" HeaderText="HostName"
  14. SortExpression="HostName" />
  15. <asp:BoundField DataField="MachineType" HeaderText="MachineType"
  16. SortExpression="MachineType" />
  17. <asp:BoundField DataField="Kernel" HeaderText="Kernel"
  18. SortExpression="Kernel" />
  19. <asp:BoundField DataField="SerialNo" HeaderText="SerialNo"
  20. SortExpression="SerialNo" />
  21. <asp:BoundField DataField="PrimaryIP" HeaderText="PrimaryIP"
  22. SortExpression="PrimaryIP" />
  23. <asp:TemplateField HeaderText="Action">
  24. <ItemTemplate>
  25. <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
  26. </ItemTemplate>
  27. <ItemStyle HorizontalAlign="Center" />
  28. <HeaderStyle HorizontalAlign="Center" />
  29. </asp:TemplateField>
  30. </Columns>
  31. <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  32. <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  33. <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  34. <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  35. <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center"
  36. VerticalAlign="Middle" Wrap="True" />
  37. <AlternatingRowStyle BackColor="White" />
  38. </asp:GridView>
Reputation Points: 38
Solved Threads: 15
Posting Pro in Training
chris5126 is offline Offline
412 posts
since Feb 2006
Apr 22nd, 2009
0

Re: how should i do it?

Change DataBinder.Eval(Container.DataItem, "Id") by DataBinder.Eval(Container.DataItem, "ServerID")
And change frmagents.aspx to your page.

Always post the error details otherwise it will be difficult for others to identify the problem.
Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009
Apr 22nd, 2009
0

Re: how should i do it?

Hi,

I still get the error ch does not exist in the current context does it need to be decalred in the aspx.cs page?:

code now reads:

ASP.NET Syntax (Toggle Plain Text)
  1. <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=monitor.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "ServerId")+ ">Delete</a>" %>'></asp:Label>
Reputation Points: 38
Solved Threads: 15
Posting Pro in Training
chris5126 is offline Offline
412 posts
since Feb 2006
Apr 22nd, 2009
0

Re: how should i do it?

YES PUT THE LINE public char ch = '"'; just above your page load method like protected void Page_Load(object sender, EventArgs e)
Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Asp.net javascript confirmation box not cancelling
Next Thread in ASP.NET Forum Timeline: Update Web.config from windows application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC