Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

dynamically set databind expression?

Posted on 2008-11-16
2
Medium Priority
?
268 Views
Last Modified: 2012-05-05
I have a GridView with a TemplateField
 <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label ID="lblDisplayItem" runat="server" Text='<%# Eval("Description") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtEditItem" runat="server" Text='<%# Eval("Description") %>' />
                            </EditItemTemplate>
                        </asp:TemplateField>

Is it possible to set the '<%# Eval("Description") %>' to another field at run time?

Any help appreciated, Thanks
0
Comment
Question by:colonel720
2 Comments
 
LVL 2

Accepted Solution

by:
yohney earned 2000 total points
ID: 22972000
try adding DataBinding event to this Label control, than in that event try this:

private void lc_DataBinding(object sender, EventArgs e)
        {
            var lc = (Label) sender;
            var container = (RepeaterItem)lc.NamingContainer;

            lc.Text = DataBinder.Eval(container.DataItem, "SOME NEW FIELD NAME");
        }

hope it helped...
0
 
LVL 1

Author Closing Comment

by:colonel720
ID: 31517278
Didn't get to test it, but I won't be taking this route after all. I am giving you the points for responding with something that  by the looks of it, works.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

564 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