i have a page where users post contents with image or can also upload and display video, my challenge is that the video needs to be uploaded in same table with data content, so if a user just types text and upload image the empty video link wont show but if uploaded video the image wont show, how do i do that using one table.
please upload a video and then use my table for an easy example
table
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[USERPost](
[ID] [int] IDENTITY(1,1) NOT NULL,
[UserName] [varchar](50) NULL,
[FriendUserName] [varchar](50) NULL,
[Title] [varchar](200) NULL,
[ContentPost] [text] NULL,
[ImageName1] [nvarchar](500) NULL,
[VideoName] [nvarchar](500) NULL,
[Description] [nvarchar](max) NULL,
[Path] [nvarchar](500) NULL,
[poster] [nvarchar](500) NULL,
[ContentType] [nvarchar](500) NULL,
[SendDate] [datetime] NULL,
[TotalCount] [int] NULL,
[ADStatus] [nvarchar](50) NULL,
CONSTRAINT [PK_USERPost] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
html
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<asp:PlaceHolder ID="PlaceHolder2" runat="server">
<!-- Captions are optional -->
<asp:HiddenField ID="HiddenField2" runat="server" Value='<%#getUserHREF2(Container.DataItem)%>' />
<a class="" href='<%#getUserHREF05(Container.DataItem)%>'>
<asp:Image ID="Image1" runat="server" src='<%#getSRCDD(Container.DataItem)%> ' class=""
Style="width: 100%" alt="" data-aria-label-part="" />
<span class="icon-focus"></span></a>
<video controls poster="" style="width: 100%" autoplay="autoplay">
<!-- Video files -->
<source src="<%# Eval("Path") %>" type="video/mp4" >
<source src="<%# Eval("Path") %>" type="video/webm">
<!-- Captions are optional -->
<!-- Text track file -->
<track kind="captions" label="English captions" src="/path/to/captions.vtt" srclang="en" default>
<!-- Fallback for browsers that don't support the <video> element -->
<!-- <a href="https://cdn.selz.com/plyr/1.5/View_From_A_Blue_Moon_Trailer-HD.mp4">
Download</a>-->
</video>
<!-- Lightbox -->
</asp:PlaceHolder>
</ItemTemplate>
</asp:DataList>
code to select
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (this.Page.User.Identity.IsAuthenticated)
{
username = this.Page.User.Identity.Name;
DataTable dt = GetProfile(username);
GetMergedAll.DataSource = dt;
ViewState["DataTable"] = dt;
GetMergedAll.DataBind();
if (dt.Rows.Count > 0)
{
GetMergedAll.DataSource = dt;
GetMergedAll.DataBind();
}
}
}
}
public DataTable GetProfile(string username)
{
SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("GetUserPOSTS", constr);
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
// adp.SelectCommand.Parameters.AddWithValue("@Email", username);
adp.SelectCommand.Parameters.AddWithValue("@UserName", username);
adp.SelectCommand.Parameters.AddWithValue("@Id", Id);
DataTable dt = new DataTable();
adp.Fill(dt);
return dt;
}
Please can you show me how to either upload image and or upload video with text