0

I have a page that displays information about items in Gridview and when the user clicks the ItemNo than it should go to the new redirected page. The following is what I have and it doesn't seem to work.
It supposed to get the ID number from the Db by using the ItemNo than redirect it self to the appropriate page.

The page should redirect to a page that has a different IP address and host name.

.aspx page

<asp:GridView ID="gvWorkOrderSum" runat="server" CellPadding="4" 
ShowFooter="True" DataKeyNames="InfoID" BorderColor="#5D7B9D" BorderWidth="2px"  OnDataBound="gvWorkOrderSum_OnDataBound"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" OnRowDeleting="gvWorkOrderSum_RowDeleting"
Caption='<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#5D7B9D"><tr><td ><span style="color: white; font-family: Arial Black">WorkOrder information</span></td></tr></table>'
DataSourceID="odsWorkOrderList">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns> 
<asp:TemplateField ShowHeader="False">

 <asp:TemplateField HeaderText="ItemNo">
 <HeaderStyle HorizontalAlign="Center" />
 <ItemStyle HorizontalAlign="Center" />
 <FooterStyle HorizontalAlign="Center" />
 <ItemTemplate>
 <asp:LinkButton ID="lbItemNo" runat="server" CommandName="OrderDetail" CommandArgument='<%#Eval("ItemNo") %>'
Text='<%# Bind("ItemNo") %>'></asp:LinkButton> 
</ItemTemplate>
</asp:GridView>

aspx.cs page

 protected void gvWorkOrderSum_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "OrderDetail")  //
{ 
int nItemNo = int.Parse(e.CommandArgument.ToString());
SqlCommand cmd = new SqlCommand("SELECT ID FROM Order_Items WHERE Item_ID =" + nItemNo);
cmd.Parameters.Add("@ID", SqlDbType.Int).Direction = ParameterDirection.Output;
InternalSalesDB.Instance.query(cmd);
Response.Redirect("Sales/Orders/OrderDetail.aspx?ID=" + (get the ID number from DB) + "&ItemNo=" + nItemNo, true);
}
0

3 Answers 3

1

You forget to add OnRowCommand to the GridView.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh I see that makes it go to the Response page now.
1

Use the OnRowCommand attribute on the GridView with the event handler gvWorkOrderSum_RowCommand

<asp:GridView ID="gvWorkOrderSum" OnRowCommand="gvWorkOrderSum_RowCommand" ...>
    ...
</asp:GridView>

Comments

0

For your last question; Try using

Response.Redirect("~\\Sales\Orders\OrderDetail.aspx?OID=" + (get the OID number from DB) + "&ItemNo=" + nItemNo, true);

1 Comment

Actually, the issue is that the redirect page is on different host name and IP address. I need to figure out how it will support that issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.