我有一个简单的表格,如下所示:
当用户单击模板字段链接按钮时,它应该发送到另一个页面并将信息填写到以下文本框中:
我希望能够填充一个 SQL 语句,该语句使用表的信息来填充数据库中的信息:
下面是我的网格视图:
<Columns>
asp:TemplateField HeaderText="Action" SortExpression="Date">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="view" >Display</asp:LinkButton>
</ItemTemplate>
<ControlStyle Width="45px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
</asp:TemplateField>
<asp:BoundField DataField="Classid" HeaderText="ID"
SortExpression="Date" >
<ItemStyle cssClass="grid_padding" />
</asp:BoundField>
<asp:BoundField DataField="Addate" HeaderText="Date" SortExpression="Date"
DataFormatString="{0:d}" >
<ItemStyle cssClass="grid_padding" />
</asp:BoundField>
<asp:BoundField DataField="username" HeaderText="User Name"
SortExpression="Date" >
<ItemStyle cssClass="grid_padding" />
</asp:BoundField>
<asp:BoundField DataField="category" HeaderText="Category" SortExpression="Date">
<ItemStyle cssClass="grid_padding" />
</asp:BoundField>
<asp:BoundField DataField="description" HeaderText="Description"
SortExpression="Date" >
<ItemStyle CssClass="grid_padding2" />
</asp:BoundField>
</Columns>
到目前为止,这是链接按钮的位置(更新:所有注释掉的行都会给我错误,因此它们不起作用):
Protected Sub DisplayClassifieds_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DisplayClassifieds.SelectedIndexChanged
Dim strSelect As String
Dim strFilter As String = " "
Dim counter As Integer = 0
Dim v As Integer = 0
'cell = DisplayClassifieds[0,Row].Value
'cell = DisplayClassifieds.Rows(e.NewSelectedIndex).Cells(0).Text
'strFilter = DisplayClassifieds.SelectedRowStyle(0).Value
strSelect = "SELECT Classid, Addate, Username, Category, Description, Fulldescription FROM TABLENAME WHERE Classid = '" & strFilter & "' "
Page.Session.Add("Display_Values", strSelect)
Response.Redirect("DispAd.aspx")
End Sub