943,539 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1111
  • ASP.NET RSS
Mar 12th, 2009
0

get data from detailview

Expand Post »
I have problem with detailview. My detail view like this:
ProductID: 1
ProductName: car
Price: 200
And when I click link button, it will appear "1"
This is the code behind:
ASP.NET Syntax (Toggle Plain Text)
  1. Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
  2. Dim detail As DetailsView = DetailsView1
  3. Dim rows As DataControlFieldCollection = detail.Fields
  4. Dim ProductID As DataControlField = rows.Item(1)
  5. Label1.Text = ProductID.ToString
  6. End Sub
But when I click link button, the text of label is "ProductID", not "1" like I want
Could you please help me? Thanks a lot!
Last edited by donaldunca; Mar 12th, 2009 at 4:54 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
donaldunca is offline Offline
27 posts
since Sep 2006
Mar 12th, 2009
0

Re: get data from detailview

hi,

i have no exp in details view.may be it can help

try like this

ASP.NET Syntax (Toggle Plain Text)
  1. <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" OnItemCommand="DetailsView1_ItemCommand">
  2. <Fields>
  3. <asp:TemplateField>
  4. <ItemTemplate>
  5. <asp:LinkButton ID="lnk" runat="server" CommandArgument='<%#Eval("Productid") %>' ></asp:LinkButton>
  6. </ItemTemplate>
  7. </asp:TemplateField>
  8. </Fields>
  9. </asp:DetailsView>
  10.  
  11. protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
  12. {
  13. if (e.CommandName == "lnk")
  14. {
  15. string id = e.CommandArgument.ToString();
  16. }
  17. }
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Mar 12th, 2009
0

Re: get data from detailview

hi,

sorry i fogot to add
ASP.NET Syntax (Toggle Plain Text)
  1. <ItemTemplate>
  2. <asp:LinkButton ID="lnk" runat="server" CommandArgument='<%#Eval("Productid") %>' CommandName="lnk"></asp:LinkButton>
  3. </ItemTemplate>
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: DataList help!
Next Thread in ASP.NET Forum Timeline: The remote server returned an error: (501) Not Implemented





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC