Answered by:
A question about Bind()

Question
-
User-36691632 posted
hey, guys
I am have a little problem in my aspx page with GridView control.
I have a bind like this:
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName=""
Text="Edit" PostBackUrl='<%# "FormEdit.aspx?RID=" + Bind("RuleID") %>'></asp:LinkButton>
</ItemTemplate>
And looks like it does not work. I am wondering how can I make it work. All I need is just to click it to FormEdit.aspx page with the RID as parameter.
Any inputs are welcome. Thanks.Saturday, March 24, 2007 10:20 PM
Answers
-
User-158764254 posted
if you're just posting to another page, i'd use a hyperlink instead of a linkbutton
Like this:
<asp:GridView ID="GridView1" runat="server"> <Columns> <asp:HyperLinkField DataNavigateUrlFields="RuleID" DataNavigateUrlFormatString="FormEdit.aspx?RID={0}" Text="Edit" /> </Columns> </asp:GridView>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 24, 2007 10:53 PM -
User-158764254 posted
Bind provides two-way binding to support editiing of the bound values.
When you are going to wrap the bound value in a function, you should use Eval (for one-way binding) instead of Bind.
So it would look more like this:GetRuleTypeDescription((int)Eval("RuleType"))
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, March 25, 2007 9:43 AM
All replies
-
User-158764254 posted
if you're just posting to another page, i'd use a hyperlink instead of a linkbutton
Like this:
<asp:GridView ID="GridView1" runat="server"> <Columns> <asp:HyperLinkField DataNavigateUrlFields="RuleID" DataNavigateUrlFormatString="FormEdit.aspx?RID={0}" Text="Edit" /> </Columns> </asp:GridView>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, March 24, 2007 10:53 PM -
User-36691632 posted
Great. It works great. Thanks a lot.Saturday, March 24, 2007 11:21 PM -
User-36691632 posted
Hey,mbanavige
I got another similar question. For example:
<asp:BoundField HeaderText="Pair Type" DataField='<# Bind("RuleType")#>' />
Here, the rule type in database is the rule type id, I have a function to GetRuleTypeDescription(int nRuleType) to get the description for the rule type. So, actually, here, I want to do something like GetRuleTypeDescription((int)Bind("RuleType")), in asp.net 1.0, seems we can do similar stuff, but in 2.0, it won't compile.Sunday, March 25, 2007 1:25 AM -
User-158764254 posted
Bind provides two-way binding to support editiing of the bound values.
When you are going to wrap the bound value in a function, you should use Eval (for one-way binding) instead of Bind.
So it would look more like this:GetRuleTypeDescription((int)Eval("RuleType"))
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, March 25, 2007 9:43 AM