开发者

Gridview button to redirect with query for row data?

开发者 https://www.devze.com 2023-03-05 07:42 出处:网络
Simple question: I have a button field in my gridview, and I want to redirect to an edit page which displays the row data. I think I need to use d开发者_开发技巧atakeys for this, but I don\'t know the

Simple question: I have a button field in my gridview, and I want to redirect to an edit page which displays the row data. I think I need to use d开发者_开发技巧atakeys for this, but I don't know the steps. How do I place the query into the response.redirect url? The identifying field is SubId.

Response.Redirect("~/View.aspx?*whatgoeshere?*");

And also, anybody know why despite my horizontal align=right selection (in design mode, so no syntax issue) my gridview insists on left-aligning one of my fields? It's autoformatted to a skin from vs.


Simply you can do like...

<ItemTemplate>
 <asp:Button ID="Edit" runat="server" Text="Edit" PostBackUrl='<%# Eval("DataKeyName", "~/View.aspx?Id={0}") %>' />
</ItemTemplate>


Have a look at my answer to this question: how to find the control OfferID?

It deals with pretty much exactly what you need to do.

Regarding the alignment, I'd recommend posting that as a separate question (with it being a totally unrelated issue) and including your markup.

EDIT: As you don't need to do anything other than redirect, I'd do what @Muhammad Akhtar says in his answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消