CSDN博客

img liushmh

how to using CommandArgument in DataGrid

发表于2004/10/12 10:35:00  659人阅读

<asp:TemplateColumn> 
 <ItemTemplate> 
  <asp:LinkButton runat="server" CommandName="Select" Text="Details" 
       CommandArgument='<%# DataBinder.Eval(Container.DataItem, "title_id") %>' /> 
 </ItemTemplate> 
</asp:TemplateColumn> 

This primary key field information could then be extracted in the ItemCommand event handler, which would look like

Sub dgTitles_ItemCommand(sender As Object, e As DataGridCommandEventArgs) 
 If e.CommandName = "Select" then 
  ' The details button has been clicked, find out the PK field value 
  Dim strTitleID as String = e.CommandArgument 

  ' Display the book's details 
  dgBookDetails.DataSource = GetBookDetails(strTitleID) 
  dgBookDetails.DataBind() 

  ' Make sure the dgBookDetails DataGrid is Visible 
  dgBookDetails.Visible = True 
 End If 
End Sub 
阅读全文
0 0

相关文章推荐

img
取 消
img