Hello everyone,
I have one GridView and two different DetailsView's on ONE SINGLE page. I'm attempting to populate a label (which is in a DetailsView and also inside an InsertItemTemplate) with a value from the GridView. Of course I have datasources (<asp:SqlDataSource>) which are feeding the GridView and two DetailsViews. I also have all the commands with the datasources (SelectCommand, InsertCommand, UpdateCommand, etc.)
The reason why I have the ONE GridView and TWO DetailsViews is because I'm working with THREE separate SQL tables.
Here's my code:
The GridView (which contains the value inside a LinkButton)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Tracker_Number" DataSourceID="TOASearchResults" Width="498px" AllowPaging="True" AllowSorting="True">
<asp:LinkButton ID="LinkButton2" CommandName="Select" Runat="Server" OnClick="ShowEdit" Text='<%# Eval("Tracker_Number") %>'/>
The DetailsView (which contains the label I want to populate)
<asp:TemplateField HeaderText="Tracker Number" SortExpression="Tracker_Number">
<EditItemTemplate>
<asp:label ID="TrackerNumber" runat="server" Text='<%# Bind("Tracker_Number") %>'></asp:label>
</EditItemTemplate>
<InsertItemTemplate>
<asp:label ID="lblTrackerNumber" runat="server"></asp:label>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="TrackerNumber" runat="server" Text='<%# Eval("Tracker_Number") %>'></asp:label>
</ItemTemplate>
</asp:TemplateField>
I basically took this project over, so this isn't even my code. However, everything works except for this little part.
Any help would be appreciated,
Thanks!
-WesSo what's populating your DetailsView? The same data source? If everything else seems to be working, I think you should step through your code to see if those statements in the DetailsView are being called. (Too bad you use inline ASP.NET! ha ha!)
I got it!
I basically passed the value of the LinkButton (which was whatever the user clicked), stored it into a label and then assigned the value of that label to the label inside my InsertItemTemplate.
Thanks for the help anyway!
Friday, March 16, 2012
Populating a label (inside InsertItemTemplate) with default value
Labels:
asp,
attempting,
default,
detailsview,
gridview,
insertitemtemplate,
inside,
label,
net,
page,
populate,
populating,
single,
value
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment