TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Subin Thomas
NA
4.9k
125.9k
multiple file upload in entity framework !
Jun 18 2019 3:10 AM
i have a code which accepts multiple file on gridview but when clickd on save it is taking only 1 file
protected
void
btnUpload_Click(object sender, EventArgs e)
{
try
{
ddlBillType_DataBound(ddlBillType, e);
DataTable dtDoc =
new
DataTable();
if
(dtDoc.Rows.Count < 0)
{
dtDoc = objTrnFVCBillAction.GetBlankDocumentListDataTable();
ViewState[
"dtAddDoc"
] = dtDoc;
lblAutoDocID.Text =
"0"
;
}
else
{
dtDoc = (DataTable)ViewState[
"dtAddDoc"
];
}
if
(ddlDocumentName.SelectedValue !=
"0"
&& fuSupDocs.FileName !=
""
)
{
DataRow dr = dtDoc.NewRow();
btnUpload.EnableViewState =
true
;
if
(btnUpload.Text ==
"Add Document"
)
{
if
(lblAutoDocID.Text ==
""
)
{
lblAutoDocID.Text =
"0"
;
}
lblAutoDocID.Text = (
long
.Parse(lblAutoDocID.Text) + 1).ToString();
dr[Constant.Auto_Gen_ID] =
long
.Parse(lblAutoDocID.Text);
}
dr[
"Document_Name"
] = ddlDocumentName.SelectedItem.Text;
if
(fuSupDocs.HasFile)
{
dr[
"Document_Name"
] = fuSupDocs.PostedFile.FileName;
string sFileName = string.Empty;
sFileName = Server.MapPath(@
"~/Temp/"
+ fuSupDocs.FileName);
fuSupDocs.SaveAs(sFileName);
dr[
"Document_URL"
] = sFileName;
}
if
(btnUpload.Text ==
"Add Document"
)
{
dtDoc.Rows.Add(dr);
ViewState[
"dtAddDoc"
] = dtDoc;
grdSuppDocs.DataSource = dtDoc;
grdSuppDocs.DataBind();
BlankDoc();
}
}
}
catch
(Exception ex)
{
Omb.ShowMessage(ex.Message,
true
);
}
}
action page code
public
DataTable GetBlankDocumentListDataTable()
{
DataTable dtDocVoucher =
new
DataTable();
dtDocVoucher.Columns.Add(Constant.Auto_Gen_ID, System.Type.GetType(
"System.Int64"
));
dtDocVoucher.Columns.Add(
"Document_Name"
, Type.GetType(
"System.String"
));
dtDocVoucher.Columns.Add(
"Document_URL"
, Type.GetType(
"System.String"
));
return
dtDocVoucher;
}
Reply
Answers (
1
)
I have got error in MVC?
ejemplo de programación con framework 4.8 de .net c# MVC