Wednesday, July 18, 2007

Jing, a Free Image Capture & Screen Recording tool

TechSmith released a free image capture / screen recorder tool yesterday called Jing. I focused on the video recording features because we have SnagIt here at work. Jing is very easy to use. I installed it, configured it (setting up Screencast), and created a video in about 10 minutes. Jing is cool because it allows you to record your entire screen, an entire application or objects within applications. After recording one click sends your video up to Screencast and even puts the URL to your video in your clipboard!

We will probably use this tool for training.

Thursday, July 12, 2007

Greater Lansing User Group .net (GLUG.net) July Meeting

Where: 1145 Engineering Building, Michigan State University

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:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:campDBConnection %>"

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>

I needed to add in the binary data into e.NewValues:

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


I also found a couple more gotchas:

  1. To format data in the grid you need to have HtmlEncode
    turned off

  2. 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.