I am really new to ASP.NET I have a gridview that I am working with and simply want to put a button on it that will fire a stored proc I have written that takes a parameter (id). The id field is bound to the datasource. Here is what I have:
That is the form. Here is the vb:
Right now I just want it to give me an indication that this vb is getting executed. Currently I see nothing happening. When my stored proc is expecting a variable, I get an error telling me that it expects a parameter that was not supplied.
How can I just put a button on the form (in a column) that will fire off an event when pressed. Currently it seems that it can only be a SELECT, EDIT, DELETE, etc type. Any help would be greatly appreciated.
Thanks,
LJ
Code:
<body>
<form id="form1" runat="server">
<uc1:checkAuthintication ID="checkAuthintication1" runat="server" />
<table width="100%">
<tr>
<td align="center" colspan="3">
<asp:Label ID="Label1" runat="server" SkinID="title" Text="Document List"></asp:Label></td>
</tr>
<tr>
<td style="width: 350px">
<asp:Label ID="Label3" runat="server" SkinID="Title" Text="Add New Document"></asp:Label></td>
<td colspan="2">
</td>
</tr>
<tr>
<td style="width: 350px">
<asp:Label ID="Label2" runat="server" Text="File Name: " Width="85px"></asp:Label>
<asp:FileUpload ID="uploadFile" runat="server" Width="250px" /></td>
<td colspan="2">
<asp:Label ID="Label4" runat="server" Text="File Description: " Width="140px"></asp:Label><asp:TextBox
ID="txtFileDescription" runat="server" MaxLength="250" Width="400px" EnableViewState="False"></asp:TextBox><asp:Button
ID="btnAddFile" runat="server" Text="Add File" Width="85px" /></td>
</tr>
</table>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="fileNewName"
DataSourceID="SqlDataSource1" AllowSorting="True" Width="100%">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="fileOldName" HeaderText="File Name" SortExpression="fileOldName" />
<asp:BoundField DataField="fileDescription" HeaderText="Description" SortExpression="fileDescription" />
<asp:BoundField DataField="createDate" HeaderText="Upload Date" SortExpression="createDate" />
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" SortExpression="id" Visible="False" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClinicalTrialsConnectionString %>"
SelectCommand="sp_getDocumentList" SelectCommandType="StoredProcedure"
DeleteCommand="sp_deleteDocument" DeleteCommandType="Text">
<SelectParameters>
<asp:Parameter Name="awardId_fk" Type="Int32" />
<asp:Parameter Name="meditechId" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
<asp:Label ID="lblMessage" runat="server" SkinID="error" Text=""></asp:Label><br />
<br />
<!--#include file ="footer.inc"-->
</form>
</body>
That is the form. Here is the vb:
Code:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
' If multiple ButtonField column fields are used, use the
' CommandName property to determine which button was clicked.
If e.CommandName = "Delete" Then
' Convert the row index stored in the CommandArgument
' property to an Integer.
Dim idx As Integer = Convert.ToInt32(e.CommandArgument)
' Get the last name of the selected author from the appropriate
' cell in the GridView control.
Dim selectedRow As GridViewRow = GridView1.Rows(idx)
Dim id_cell As TableCell = selectedRow.Cells(4)
Dim my_id As String = id_cell.Text
' Display the selected author.
lblMessage.Text = e.CommandName
txtFileDescription.Text = "ID = " & my_id
End If
End Sub
Right now I just want it to give me an indication that this vb is getting executed. Currently I see nothing happening. When my stored proc is expecting a variable, I get an error telling me that it expects a parameter that was not supplied.
How can I just put a button on the form (in a column) that will fire off an event when pressed. Currently it seems that it can only be a SELECT, EDIT, DELETE, etc type. Any help would be greatly appreciated.
Thanks,
LJ