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:

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Dim detail As DetailsView = DetailsView1
        Dim rows As DataControlFieldCollection = detail.Fields
        Dim ProductID As DataControlField = rows.Item(1)
        Label1.Text = ProductID.ToString
   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!


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

try like this

<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" OnItemCommand="DetailsView1_ItemCommand">
      <asp:LinkButton ID="lnk" runat="server" CommandArgument='<%#Eval("Productid") %>' ></asp:LinkButton>

protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
        if (e.CommandName == "lnk")
           string id = e.CommandArgument.ToString();


sorry i fogot to add

      <asp:LinkButton ID="lnk" runat="server" CommandArgument='<%#Eval("Productid") %>'  CommandName="lnk"></asp:LinkButton>