Wednesday, July 18, 2007
Jing, a Free Image Capture & Screen Recording tool
We will probably use this tool for training.
Thursday, July 12, 2007
Greater Lansing User Group .net (GLUG.net) July Meeting
When: Thursday July 19th 6:00-8:00 PM
What: We always have give away hundreds or thousands of dollars worth of swag along with free pizza and pop for everyone. This month we will also be announcing the opening of the Flint branch and our Vice President Vivek has secured all our membership 100 MB of free hosting from Verio.
Julia Lerman will be our first female speaker. She will be presenting on ADO.NET Entity Framework.
Visit our website for more details: www.glugnet.org
Friday, July 6, 2007
Updating Binary Data in a Gridview
Our customer needed the ability to update an image in a database. I wanted them to be able to view and edit all the data through the datagrid.
In your data source you need to specify the select command to display the data and the updateCommand to update the data:
SelectCommand="usp_CAMP_get_rejected_batches"
SelectCommandType="StoredProcedure"
UpdateCommand="usp_camp_resubmit_deposit_ticket"
UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="deposit_id" Type="Int32" />
<asp:Parameter Name="deposit_slip_no" Type="String" />
<asp:Parameter Name="deposit_date" Type="DateTime" />
<asp:Parameter Name="Amount" Type="Decimal" />
<asp:Parameter Name="image" /> </UpdateParameters>
</asp:SqlDataSource>
I used a TemplateField to include the FileUpload control which allows a user to select a file from their computer for upload. This also allowed the same column to be used to display the image and change it.
<asp:TemplateField HeaderText="Deposit Ticket">
<EditItemTemplate>
<asp:FileUpload ID="imgUpload" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:Image ImageUrl='<%#DataBinder.Eval(Container.DataItem, "DEPOSIT_IMAGE_URL")%>' runat = "server" />
</ItemTemplate>
</asp:TemplateField>
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
e.NewValues.Add("image", CType(GridView1.Rows(e.RowIndex).Cells.Item(5).Controls(1), FileUpload).FileBytes)
End Sub
- To format data in the grid you need to have HtmlEncode
turned off - For the upldate to send the primary key field and have that field set to invisible you need to specify the primary key in the DataKeyNames property for the GridView.