RE: File Upload control not working in Datagrid



Hi Tyler,

I think it should not be related to language of the WebForm. I've included
a self-contained Webform in VB.NET for your reference:

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<script runat="server">
Protected Sub grid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs)
grid1.EditItemIndex = e.Item.ItemIndex
BindGrid()
End Sub

Protected Sub grid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim file1 As FileUpload = CType(FindControlRecursive(e.Item,
"file1"), FileUpload)
Response.Write(file1.HasFile)
grid1.EditItemIndex = -1
BindGrid()
End Sub

Protected Sub grid1_CancelCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs)
grid1.EditItemIndex = -1
BindGrid()
End Sub

Private Sub BindGrid()
grid1.DataSource = New Integer(5) {}
grid1.DataBind()
End Sub

Public Shared Function FindControlRecursive(ByVal root As Control,
ByVal id As String) As Control
If (root.ID Is id) Then
Return root
End If
Dim c As Control
For Each c In root.Controls
Dim t As Control = FindControlRecursive(c, id)
If (Not t Is Nothing) Then
Return t
End If
Next
Return Nothing
End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not IsPostBack Then
BindGrid()
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml"; >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataGrid ID="grid1" runat="server"
OnEditCommand="grid1_EditCommand" OnUpdateCommand="grid1_UpdateCommand"
OnCancelCommand="grid1_CancelCommand">
<Columns>
<asp:TemplateColumn>
<EditItemTemplate>
<asp:FileUpload ID="file1" runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" UpdateText="OK"
CancelText="Cancel"></asp:EditCommandColumn>
</Columns>
</asp:DataGrid>
</div>
</form>
</body>
</html>



Please verify if this works on your side. Would you please also post your
code here? Thanks.


Regards,
Walter Wang (wawang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: how to get selectedvalue of radiobuttonlist in Javascript?
    ... could "find" the control and backfit the ClientID. ... Dim dt As New Data.DataTable ... Protected Sub RadioButtonList1_DataBound(ByVal sender As Object, ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Date variable doesnt retain its value in select case statement?
    ... property of a custom control in step 2. ... Protected Sub AddNewsWizard_NextButtonClick(ByVal sender As Object, ... 'Dim NewsHelper As New NewsManager ... ' AddNewsResultsLabel.Text = "The news article has been saved." ...
    (microsoft.public.dotnet.framework.aspnet)
  • A simple Login Application using VS2005 Visual Web Express
    ... I wanted to develop a very simple login application by using VS 2005 Visual Web Express. ... LoginStatus1 control ... If user is admin, load the page called demo and display everything on this page ... Protected Sub Login1_LoggedInHandles Login1.LoggedIn ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RadioButtonList, Web User Control, Firefox, IE
    ... "CreateChildControls" are the prefered place for dynamic controls though it ... moving the code to create the control to OnInit or CreateChildControls ... Protected Sub Page_Load(ByVal sender As Object, ... the SelectedIndex property of my control returns the correct value. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RadioButtonList, Web User Control, Firefox, IE
    ... By the way, in the sample I load the controls in the Page Load event, but in ... moving the code to create the control to OnInit or CreateChildControls ... Protected Sub Page_Load(ByVal sender As Object, ... This control has a property that exposes the SelectedIndex property of the ...
    (microsoft.public.dotnet.framework.aspnet)

Loading