Sub detailsClicked(sender as Object, e As DataGridCommandEventArgs) Dim buttonColumn as TableCell = e.Item.Cells(0) Dim FAQIDColumn as TableCell = e.Item.Cells(1) Dim DescColumn as TableCell = e.Item.Cells(2) Dim buttonColText as String = buttonColumn.Text Dim FAQIDColText as String = FAQIDColumn.Text Dim DescColText as String = DescColumn.Text End Sub
Value of Clicked Button Column Text: Value of FAQID Column Text: 181 Value of Clicked Description Column Text: How can I format numbers and date/times using ASP.NET? For example, I want to format a number as a currency.
FAQ Details
FAQ ID
FAQ Description
144
Where can I host my ASP Web site for free (similar to GeoCities or Tripod or any of the many other free Web site sites)?
181
How can I format numbers and date/times using ASP.NET? For example, I want to format a number as a currency.
…
源代码
<% @Import Namespace="System.Data" %> <% @Import Namespace="System.Data.SqlClient" %> <script language="vb" runat="server"> Sub Page_Load(sender as Object, e as EventArgs) If Not Page.IsPostBack then BindData() End If End Sub Sub BindData() '1. Create a connection Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
'2. Create the command object, passing in the SQL string Const strSQL as String = "sp_Popularity" Dim myCommand as New SqlCommand(strSQL, myConnection)
'Set the datagrid's datasource to the datareader and databind
myConnection.Open() dgPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection) dgPopularFAQs.DataBind() End Sub
Sub dispDetails(sender as Object, e As DataGridCommandEventArgs) Dim buttonColumn as TableCell = e.Item.Cells(0) Dim FAQIDColumn as TableCell = e.Item.Cells(1) Dim DescColumn as TableCell = e.Item.Cells(2) Dim buttonColText as String = buttonColumn.Text Dim FAQIDColText as String = FAQIDColumn.Text Dim DescColText as String = DescColumn.Text lblBCT.Text = buttonColText lblFCT.Text = FAQIDColText lblDCT.Text = DescColText End Sub </script>
<script language="vb" runat="server"> Sub Page_Load(sender as Object, e as EventArgs) If Not Page.IsPostBack then BindData() 'Only bind the data on the first page load End If End Sub Sub BindData() 'Make a connection to the database 'Databind the DataReader results to the gPopularFAQs DataGrid. End Sub
Sub detailsClicked(sender as Object, e As DataGridCommandEventArgs) 'Get detailed information about the selected FAQ and bind 'the database results to the dgFAQDetails DataGrid End Sub </script>
Where can I host my ASP Web site for free (similar to GeoCities or Tripod or any of the many other free Web site sites)?
…
源代码
<% @Import Namespace="System.Data" %> <% @Import Namespace="System.Data.SqlClient" %> <script language="vb" runat="server"> Sub Page_Load(sender as Object, e as EventArgs) If Not Page.IsPostBack then BindData() End If End Sub Sub BindData() '1. Create a connection Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
'2. Create the command object, passing in the SQL string Const strSQL as String = "sp_Popularity" Dim myCommand as New SqlCommand(strSQL, myConnection)
'Set the datagrid's datasource to the datareader and databind myConnection.Open() dgPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection) dgPopularFAQs.DataBind() End Sub
Sub dispDetails(sender as Object, e As DataGridCommandEventArgs) Dim FAQID as Integer = Convert.ToInt32(e.Item.Cells(1).Text) 'Get information about the particular FAQ Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
'2. Create the command object, passing in the SQL string Dim strSQL as String = "spGetFAQ" Dim myCommand as New SqlCommand(strSQL, myConnection)
myCommand.CommandType = CommandType.StoredProcedure ' Add Parameters to SPROC Dim parameterFAQId as New SqlParameter("@FAQID", SqlDbType.Int, 4) parameterFAQId.Value = FAQID myCommand.Parameters.Add(parameterFAQId)
'Set the datagrid's datasource to the datareader and databind myConnection.Open() dgFAQDetails.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection) dgFAQDetails.DataBind() dgFAQDetails.Visible = True'Make the FAQ Details DataGrid visible End Sub </script>