Per la tua 2a domanda:
(gv è la gridview)
codice:
<Columns>
<asp:BoundField DataField="x" HeaderText="x" />
<asp:BoundField DataField="y" HeaderText="y" />
<asp:BoundField DataField="z" HeaderText="z" />
<asp:TemplateField>
<ItemTemplate>
StatoNormale
</ItemTemplate>
<EditItemTemplate>
<asp:Image ID="imgAnteprima" runat="server" ImageUrl="../img/img_iniziale.png" />
<input id="fileupload_img" name="fileupload_img" type="file" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Link" EditText="Edita" ShowEditButton="true" />
</Columns>
codice:
Protected Sub gv_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv.RowCreated
If e.Row.RowState = DataControlRowState.Edit Then
Dim img As New Image
img = e.Row.FindControl("imgAnteprima")
Dim idImmagine As String = img.ClientID
Dim upload As New HtmlControls.HtmlInputFile
upload = e.Row.FindControl("fileupload_img")
Dim idFileUpload As String = upload.ClientID
upload.Attributes.Add("onchange", "document.getElementById('" & idImmagine & "').src=document.getElementById('" & idFileUpload & "').value;")
End If
End Sub
Protected Sub gv_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gv.RowEditing
gv.EditIndex = e.NewEditIndex
bindgrid() ' Metodo che fa una query ed il Bind
End Sub