RE: File Upload control not working in Datagrid
- From: wawang@xxxxxxxxxxxxxxxxxxxx (Walter Wang [MSFT])
- Date: Wed, 10 Jan 2007 03:02:45 GMT
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.
.
- Follow-Ups:
- RE: File Upload control not working in Datagrid
- From: Walter Wang [MSFT]
- RE: File Upload control not working in Datagrid
- References:
- RE: File Upload control not working in Datagrid
- From: Walter Wang [MSFT]
- RE: File Upload control not working in Datagrid
- From: Tyler Wilson
- RE: File Upload control not working in Datagrid
- Prev by Date: RE: File Upload control not working in Datagrid
- Next by Date: Datagrid Data loaded twice
- Previous by thread: RE: File Upload control not working in Datagrid
- Next by thread: RE: File Upload control not working in Datagrid
- Index(es):
Relevant Pages
|
Loading