ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Get image name from image Path from FormView and save in Database using C# in ASP.Net<p>Hi <a class="username" rel="micah"> micah,</a></p> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">string img = (SharePost.Row.FindControl(&#34;img&#34;) as Image).;</pre> <p>Replace above code with below.</p> <pre class="brush: csharp"> string img = (SharePost.Row.FindControl(&#34;img&#34;) as Image).ImageUrl;</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 13 Dec 2016 02:04:08 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>what of this </p> <pre class="brush: csharp">private void InsertDatabase(string userName, string fuserName, string contentPost, DateTime sendDate, string modelId, string comment) { using (SqlConnection con = new SqlConnection(constrr)) { using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO USERPost VALUES(@UserName,@FriendUserName,@ContentPost,,@ImageName1,@SendDate,@ShareId,@Comments,@FriendImageName,@null,@null)&#34;, con)) { // cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@UserName&#34;, username = this.Page.User.Identity.Name); cmd.Parameters.AddWithValue(&#34;@FriendUserName&#34;, fuserName); cmd.Parameters.AddWithValue(&#34;@ContentPost&#34;, contentPost); cmd.Parameters.AddWithValue(&#34;@SendDate&#34;, sendDate); cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@Comments&#34;, comment); cmd.Parameters.AddWithValue(&#34;@FriendImageName&#34;, img2); cmd.Parameters.AddWithValue(&#34;@TotalCount&#34;, ); cmd.Parameters.AddWithValue(&#34;@ADStatus&#34;, ); cmd.Parameters.AddWithValue(&#34;@ImageName1&#34;, umg); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } }</pre> <p>the problem i have with this code above it that those rows that does not have data to insert is causing error when trying to insert</p> <p>it tells me number of supplies not match the number of columns. So i decided to insert null into those rows. do you know how to handel that?</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 13 Dec 2016 02:30:42 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>Hi <a class="username" rel="micah"> micah</a>,</p> <p><span style="text-decoration: underline;">&nbsp;C#</span></p> <pre class="brush: csharp">private void InsertDatabase(string userName, string fuserName, string contentPost, DateTime sendDate, string modelId, string comment) { using (SqlConnection con = new SqlConnection(constrr)) { using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO USERPost VALUES(@UserName,@FriendUserName,@ContentPost,,@ImageName1,@SendDate,@ShareId,@Comments,@FriendImageName,@null,@null)&#34;, con)) { // cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@UserName&#34;, username = this.Page.User.Identity.Name); cmd.Parameters.AddWithValue(&#34;@FriendUserName&#34;, fuserName); cmd.Parameters.AddWithValue(&#34;@ContentPost&#34;, contentPost); cmd.Parameters.AddWithValue(&#34;@SendDate&#34;, sendDate); cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@Comments&#34;, comment); cmd.Parameters.AddWithValue(&#34;@FriendImageName&#34;, img2); cmd.Parameters.AddWithValue(&#34;@TotalCount&#34;, ); cmd.Parameters.AddWithValue(&#34;@ADStatus&#34;, ); cmd.Parameters.AddWithValue(&#34;@ImageName1&#34;, umg); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } }</pre> <p>Replace above code with below.</p> <pre class="brush: csharp">private void InsertDatabase(string userName, string fuserName, string contentPost, DateTime sendDate, string modelId, string comment) { using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO USERPost VALUES(@UserName,@FriendUserName,@ContentPost,@ImageName1,@SendDate,@ShareId,@Comments,@FriendImageName)&#34;, con)) { // cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@UserName&#34;, username = this.Page.User.Identity.Name); cmd.Parameters.AddWithValue(&#34;@FriendUserName&#34;, fuserName); cmd.Parameters.AddWithValue(&#34;@ContentPost&#34;, contentPost); cmd.Parameters.AddWithValue(&#34;@ImageName1&#34;, umg); cmd.Parameters.AddWithValue(&#34;@SendDate&#34;, sendDate); cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@Comments&#34;, comment); cmd.Parameters.AddWithValue(&#34;@FriendImageName&#34;, img2); cmd.Parameters.AddWithValue(&#34;@TotalCount&#34;, DBNull.Value); cmd.Parameters.AddWithValue(&#34;@ADStatus&#34;, DBNull.Value); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } }</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 13 Dec 2016 02:54:25 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>error</p> <pre class="brush: csharp">Server Error in &#39;/&#39; Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 101: string contentPost = (SharePost.Row.FindControl(&#34;lblpost&#34;) as Label).Text; Line 102: string comment = (SharePost.Row.FindControl(&#34;txtcommentshare&#34;) as TextBox).Text; Line 103: string img = (SharePost.Row.FindControl(&#34;Img&#34;) as Image).ImageUrl; Line 104: Line 105:</pre> <p>&nbsp;html markup</p> <pre class="brush: html"> &lt;img src=&#39;&lt;%#getSRCfuser(Container.DataItem)%&gt;&#39; ID=&#34;Img&#34; class=&#34;media-object img-rounded animated fadeInDown&#34; style=&#34; width:45px; height:45px; &#34; data-toggle=&#34;tooltip&#34; title=&#34;Profile Photo&#34;/&gt; </pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 13 Dec 2016 05:50:26 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>it still didnt work, still same error.</p> <p>please let me pase the whole code, i call users post from datalist to formview in modal popup, then insert that post of the user into another table, i have done that and its working. my challenge is to also fetch the image of the user in that post and insert it along side with the post. see example here</p> <p>http://www.aspforums.net/Threads/161293/Insert-Bootstrap-Modal-Popup-data-into-Database-using-C-in-ASPNet/</p> <p>this is the codes</p> <p>html</p> <p>&nbsp;</p> <pre class="brush: html">&lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#39;text/javascript&#39;&gt; function openModal() { $(&#39;#myModal&#39;).modal(&#39;show&#39;); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;asp:ScriptManager ID=&#34;ScriptManager1&#34; runat=&#34;server&#34; /&gt; &lt;asp:UpdatePanel ID=&#34;updResult&#34; runat=&#34;server&#34; UpdateMode=&#34;Conditional&#34;&gt; &lt;ContentTemplate&gt; &lt;asp:DataList ID=&#34;GetMergedAll&#34; runat=&#34;server&#34; DataKeyName=&#34;CategoryID&#34; OnItemCommand=&#34;GetMergedAll_ItemCommand1&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;Label1&#34; runat=&#34;server&#34; Text=&#39;&lt;%#DataBinder.Eval(Container.DataItem,&#34;CategoryName&#34;) %&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;&#34; Font-Size=&#34;&#34; /&gt; &lt;/h4&gt; &lt;asp:Label ID=&#34;lblpost&#34; runat=&#34;server&#34; Text=&#39;&lt;%# Eval(&#34;Description&#34;)%&gt;&#39; Font-Names=&#34;Comic Sans MS&#34; Font-Bold=&#34;False&#34; Font-Strikeout=&#34;False&#34; ForeColor=&#34;#333333&#34;&gt; &lt;/asp:Label&gt; &lt;asp:Button ID=&#34;btnClick&#34; Text=&#34;Click&#34; runat=&#34;server&#34; CommandName=&#34;SharePost&#34; CommandArgument=&#39;&lt;%#DataBinder.Eval(Container.DataItem,&#34;CategoryID&#34;) %&gt;&#39; OnClick=&#34;btnClick_Click&#34; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;div id=&#34;myModal&#34; class=&#34;modal fade&#34; role=&#34;dialog&#34;&gt; &lt;div class=&#34;modal-dialog&#34;&gt; &lt;!-- Modal content--&gt; &lt;div class=&#34;modal-content&#34;&gt; &lt;div class=&#34;modal-header&#34;&gt; &lt;button type=&#34;button&#34; class=&#34;close&#34; data-dismiss=&#34;modal&#34;&gt; &amp;times;&lt;/button&gt; &lt;h4 class=&#34;modal-title&#34;&gt; Modal Header&lt;/h4&gt; &lt;/div&gt; &lt;div class=&#34;modal-body&#34;&gt; &lt;asp:UpdatePanel ID=&#34;UpdatePanel2model&#34; runat=&#34;server&#34;&gt; &lt;ContentTemplate&gt; &lt;p&gt; &lt;/p&gt; &lt;br /&gt; &lt;asp:FormView ID=&#34;SharePost&#34; runat=&#34;server&#34; CssClass=&#34; table table-bordered table-striped table-hover&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:TextBox ID=&#34;txtComment&#34; runat=&#34;server&#34; placeholder=&#34;Add Comment... &#34; TextMode=&#34;MultiLine&#34; CssClass=&#34;form-control&#34; Height=&#34;80px&#34;&gt;&lt;/asp:TextBox&gt; &lt;!-- Conversations are loaded here --&gt; &lt;div class=&#34;&#34;&gt; &lt;!-- Message. Default to the left --&gt; &lt;div class=&#34;&#34; style=&#34;margin-bottom: 1px; margin-left: 8px; margin-top: 8px; margin-right: 8px&#34;&gt; &lt;div class=&#34; &#34; style=&#34;&#34;&gt; &lt;ul class=&#34;media-list&#34;&gt; &lt;li class=&#34;media&#34;&gt; &lt;div class=&#34;media-body&#34;&gt; &lt;h5 class=&#34;media-heading&#34;&gt; &lt;asp:Label ID=&#34;lblCategoryId&#34; runat=&#34;server&#34; Text=&#39;&lt;%#Eval(&#34;CategoryID&#34;)%&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;#666666&#34; /&gt; &nbsp;&lt;a&nbsp; style=&#34;margin-bottom:2px;&#34;&gt; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;img src=&#39;&lt;%#getSRCfuser(Container.DataItem)%&gt;&#39;&nbsp; class=&#34;media-object img-rounded animated fadeInDown&#34; style=&#34; width:45px; height:45px; &#34;&nbsp; data-toggle=&#34;tooltip&#34; title=&#34;Profile Photo&#34;/&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &lt;/a&gt; &lt;asp:Label ID=&#34;lblCategoryName&#34; runat=&#34;server&#34; Text=&#39;&lt;%#Eval(&#34;CategoryName&#34;)%&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;#666666&#34; /&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblDescription&#34; runat=&#34;server&#34; Text=&#39;&lt;%#Eval(&#34;Description&#34;)%&gt;&#39; Font-Size=&#34;X-Small&#34; Font-Bold=&#34;True&#34; ForeColor=&#34;Gray&#34; /&gt; &lt;div class=&#34;clearfix&#34;&gt; &lt;/div&gt; &lt;/h5&gt; &lt;div class=&#34; col-lg-12&#34; style=&#34;margin-top: 2px; margin-bottom: 2px&#34;&gt; &lt;/div&gt; &lt;!-- Nested media object --&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;!--/.direct-chat-messages--&gt; &lt;!-- Contacts are loaded here --&gt; &lt;/div&gt; &lt;!-- /.box-body --&gt; &lt;asp:Button ID=&#34;btnSubmit&#34; type=&#34;button&#34; Text=&#34;Submit&#34; OnClick=&#34;OnSubmit&#34; class=&#34;btn btn-default&#34; runat=&#34;server&#34; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:FormView&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:PostBackTrigger ControlID=&#34;GetMergedAll&#34; /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;/div&gt; &lt;div class=&#34;modal-footer&#34;&gt; &lt;button type=&#34;button&#34; class=&#34;btn btn-default&#34; data-dismiss=&#34;modal&#34;&gt; Close&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt;</pre> <p>code</p> <p>&nbsp;</p> <pre class="brush: csharp">System.Text.StringBuilder sb = new System.Text.StringBuilder(); private string constring = ConfigurationManager.ConnectionStrings["Constring"].ToString(); protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (!this.IsPostBack) { DataTable dt = GetData(); ViewState["DataTable"] = dt; GetMergedAll.DataSource = dt; GetMergedAll.DataBind(); } } } private static DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn("CategoryID", typeof(int)), new DataColumn("CategoryName"), new DataColumn("Description") }); dt.Rows.Add(1, "Category 1", "Description 1"); dt.Rows.Add(2, "Category 2", "Description 2"); dt.Rows.Add(3, "Category 3", "Description 3"); dt.Rows.Add(4, "Category 4", "Description 4"); return dt; } protected void btnClick_Click(object sender, EventArgs e) { ClientScript.RegisterStartupScript(this.GetType(), "Pop", "openModal();", true); } protected void GetMergedAll_ItemCommand1(object source, DataListCommandEventArgs e) { if (e.CommandName == "SharePost") { int index = Convert.ToInt32(e.CommandArgument); DataTable dt = (DataTable)ViewState["DataTable"]; IEnumerable&lt;DataRow&gt; query = from i in dt.AsEnumerable() where i.Field&lt;int&gt;("CategoryID").Equals(index) select i; DataTable detailTable = query.CopyToDataTable(); SharePost.DataSource = detailTable; SharePost.DataBind(); } } protected void OnSubmit(object sender, EventArgs e) { string modelId = (SharePost.Row.FindControl("lblCategoryId") as Label).Text; string userName = (SharePost.Row.FindControl("lblCategoryName") as Label).Text; string description = (SharePost.Row.FindControl("lblDescription") as Label).Text; string contentPost = (SharePost.Row.FindControl("txtComment") as TextBox).Text; &nbsp;string img = (SharePost.Row.FindControl("Img") as System.Web.UI.WebControls.Image).ImageUrl; DateTime sendDate = DateTime.Now; InsertDatabase(modelId, userName, description, contentPost, sendDate); sb.Append(@"&lt;script type='text/javascript'&gt;"); sb.Append("$(function () {"); sb.Append(" $('#myModal').modal('hide');});"); sb.Append("&lt;/script&gt;"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModelScript", sb.ToString(), false); } private void InsertDatabase(string modelId, string userName, string description, string contentPost, DateTime sendDate) { using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand("INSERT INTO SharePost VALUES(@ModelId,@userName,@contentPost,@description,@sendDate)", con)) { cmd.Parameters.AddWithValue("@ModelId", modelId); cmd.Parameters.AddWithValue("@userName", userName); cmd.Parameters.AddWithValue("@contentPost", contentPost); cmd.Parameters.AddWithValue("@description", description); cmd.Parameters.AddWithValue("@sendDate", sendDate); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } }</pre> <p>&nbsp;</p> <p>&nbsp;error</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <pre class="brush: csharp">Server Error in &#39;/&#39; Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 101: string contentPost = (SharePost.Row.FindControl(&#34;lblpost&#34;) as Label).Text; Line 102: string comment = (SharePost.Row.FindControl(&#34;txtcommentshare&#34;) as TextBox).Text; Line 103: string img = (SharePost.Row.FindControl(&#34;Img&#34;) as System.Web.UI.WebControls.Image).ImageUrl; Line 104: Line 105:</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 13 Dec 2016 23:23:06 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>Hi <a class="username" rel="micah">micah</a>,</p> <p>From where you are displaying the image in the modal popup.</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Thu, 15 Dec 2016 09:41:27 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>&nbsp;</p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (!this.IsPostBack) { username = this.Page.User.Identity.Name; DataTable dt = GetProfile(); GetMergedAll.DataSource = dt; ViewState[&#34;DataTable&#34;] = dt; GetMergedAll.DataSource = dt; GetMergedAll.DataBind(); // if (dt.Rows.Count &gt; 0) { } } } } public DataTable GetProfile() { SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings[&#34;con&#34;].ConnectionString); SqlDataAdapter adp = new SqlDataAdapter(&#34;GetUserPOSTS&#34;, constr); adp.SelectCommand.CommandType = CommandType.StoredProcedure; // adp.SelectCommand.Parameters.AddWithValue(&#34;@Email&#34;, username); adp.SelectCommand.Parameters.AddWithValue(&#34;@UserName&#34;, username); adp.SelectCommand.Parameters.AddWithValue(&#34;@Id&#34;, Id); DataTable dt = new DataTable(); // adp.Fill(dt); return dt; } protected void linkbtn_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), &#34;Pop&#34;, &#34;openModal();&#34;, true); } protected void GetMergedAll_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == &#34;SharePost&#34;) { int index = Convert.ToInt32(e.CommandArgument); DataTable dt = (DataTable)ViewState[&#34;DataTable&#34;]; IEnumerable&lt;DataRow&gt; query = from i in dt.AsEnumerable() where i.Field&lt;int&gt;(&#34;Id&#34;).Equals(index) select i; DataTable detailTable = query.CopyToDataTable(); SharePost.DataSource = detailTable; SharePost.DataBind(); } } protected void btnSharenow_Click(object sender, EventArgs e) { string modelId = (SharePost.Row.FindControl(&#34;lblModalId&#34;) as Label).Text; string userName = (SharePost.Row.FindControl(&#34;lblUserName&#34;) as Label).Text; string fuserName = (SharePost.Row.FindControl(&#34;lblfUserName&#34;) as Label).Text; string contentPost = (SharePost.Row.FindControl(&#34;lblpost&#34;) as Label).Text; string comment = (SharePost.Row.FindControl(&#34;txtcommentshare&#34;) as TextBox).Text; string img = (SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl; string img2 = (SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl; string fname = (SharePost.Row.FindControl(&#34;lblfname&#34;) as Label).Text; DateTime sendDate = DateTime.Now; InsertDatabase(userName, fuserName, contentPost, sendDate, modelId, comment, img, img2, fname); sb.Append(@&#34;&lt;script type=&#39;text/javascript&#39;&gt;&#34;); sb.Append(&#34;$(function () {&#34;); sb.Append(&#34; $(&#39;#myModal9t&#39;).modal(&#39;hide&#39;);});&#34;); sb.Append(&#34;&lt;/script&gt;&#34;); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), &#34;ModelScript&#34;, sb.ToString(), false); } private void InsertDatabase(string userName, string fuserName, string contentPost, DateTime sendDate, string modelId, string comment, string img, string img2, string fname ) { using (SqlConnection con = new SqlConnection(constrr)) { using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO USERPost VALUES(@UserName,@FriendUserName,@ContentPost,@SendDate,@ShareId,@Comments,@ImageName3,@ImageName1,@fName,@TotalCount)&#34;, con)) { // cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@UserName&#34;, username = this.Page.User.Identity.Name); cmd.Parameters.AddWithValue(&#34;@FriendUserName&#34;, userName); cmd.Parameters.AddWithValue(&#34;@ContentPost&#34;, contentPost); cmd.Parameters.AddWithValue(&#34;@SendDate&#34;, sendDate); cmd.Parameters.AddWithValue(&#34;@ShareId&#34;, modelId); cmd.Parameters.AddWithValue(&#34;@Comments&#34;, comment); cmd.Parameters.AddWithValue(&#34;@ImageName3&#34;, img); cmd.Parameters.AddWithValue(&#34;@ImageName1&#34;, img2); cmd.Parameters.AddWithValue(&#34;@fName&#34;, fname); cmd.Parameters.AddWithValue(&#34;@TotalCount&#34;, comment); // cmd.Parameters.AddWithValue(&#34;@ADStatus&#34;, comment); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } } </pre> <p> html model pop up</p> <p>&nbsp;</p> <pre class="brush: html">&lt;!-- Trigger the modal with a button --&gt;&lt;!-- Modal share POST MODAL --&gt; &lt;div class=&#34;modal fade&#34; id=&#34;myModal9t&#34; role=&#34;dialog&#34; style=&#34;display: none&#34; data-backdrop=&#34;static&#34; &gt; &lt;div class=&#34;modal-dialog&#34;&gt; &lt;!-- Modal content--&gt; &lt;div class=&#34;modal-content&#34;&gt; &lt;div class=&#34;modal-header&#34;&gt; &lt;button type=&#34;buttonclose&#34; class=&#34;close&#34; data-dismiss=&#34;modal&#34;&gt;&amp;times;&lt;/button&gt;&lt;h4 class=&#34;modal-title&#34; style=&#34;color: #999999&#34;&gt;Pass To Your Followers? &lt;/h4&gt;&lt;div class=&#34;&#34; &gt; &lt;/div&gt; &lt;/div&gt; &lt;asp:UpdatePanel ID=&#34;UpdatePanel2model&#34; runat=&#34;server&#34;&gt; &lt;ContentTemplate&gt; &lt;asp:FormView ID=&#34;SharePost&#34; runat=&#34;server&#34; CssClass=&#34; &#34;&gt; &lt;ItemTemplate&gt; &lt;div class=&#34;modal-body&#34; style=&#34;background-color:#e8f5fd;&#34;&gt; &lt;asp:TextBox ID=&#34;txtcommentshare&#34; runat=&#34;server&#34; placeholder=&#34;Add Comment... &#34; TextMode=&#34;MultiLine&#34; CssClass=&#34;form-control&#34; Rows=&#34;1&#34; Font-Bold=&#34;False&#34; Font-Names=&#34;Comic Sans MS&#34; &gt;&lt;/asp:TextBox&gt;&lt;/div&gt;&lt;div class=&#34;modal-body&#34; style=&#34;&#34;&gt; &lt;!-- Conversations are loaded here --&gt;&lt;div class=&#34;&#34;&gt; &lt;!-- Message. Default to the left --&gt; &lt;div class=&#34;&#34; style=&#34;margin-bottom:1px; margin-left:8px; margin-top:8px; margin-right:8px&#34;&gt; &lt;div class=&#34;&#34;&gt; &lt;div class=&#34;&#34; style=&#34;margin-bottom:1px; margin-top:1px&#34;&gt; &lt;div class=&#34;&#34; style=&#34;margin-top:2px;margin-bottom:2px; font-variant-caps:titling-caps&#34;&gt; &lt;div class=&#34;&#34;&gt; &lt;div class=&#34;&#34; style=&#34;margin-bottom:1px; margin-top:1px&#34;&gt; &lt;div &gt; &lt;div class=&#34;dropdown&#34;&gt; &lt;ul class=&#34;media-list&#34; style=&#34;margin-bottom:2px;&#34;&gt; &lt;li class=&#34;media&#34; style=&#34;margin-bottom:2px;&#34;&gt; &lt;i class=&#34;pull-right&#34; style=&#34;&#34; &gt; &lt;i class=&#34;&#34; style=&#34;color: #999999&#34;&gt;&lt;/i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href=&#34;#&#34; class=&#34;dropdown-toggle &#34; data-toggle=&#34;dropdown&#34; &gt;&lt;asp:Label ID=&#34;Label15&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-chevron-down&#34;&gt;&lt;/asp:Label&gt;&lt;/a&gt;&lt;ul class=&#34;dropdown-menu&#34; role=&#34;menu&#34; style=&#34;font-style: normal&#34;&gt; &lt;li&gt;&lt;a href=&#34;#&#34;&gt;&lt;i class=&#34;fa fa-warning&#34;&gt;&lt;/i&gt;Report Post&lt;/a&gt;&lt;/li&gt;&lt;li class=&#34;divider&#34;&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&#34;#&#34;&gt;&lt;i class=&#34;fa fa-bookmark-o&#34;&gt;&lt;/i&gt;Save Post&lt;/a&gt;&lt;/li&gt;&lt;li class=&#34;divider&#34;&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=&#34;#&#34;&gt;&lt;i class=&#34;fa fa-copy&#34;&gt;&lt;/i&gt;Copy link&lt;/a&gt;&lt;/li&gt;&lt;li class=&#34;divider&#34;&gt;&lt;/li&gt; &lt;li&gt; &lt;asp:LinkButton ID=&#34;btndeletepost&#34; runat=&#34;server&#34;&gt; &lt;i class=&#34;glyphicon glyphicon-erase&#34;&gt;&lt;/i&gt;Delete&lt;/asp:LinkButton&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/i&gt;&lt;a class=&#34;pull-left&#34; href=&#39;&lt;%#getUserHREF05(Container.DataItem)%&gt;&#39; style=&#34;margin-bottom:2px;&#34;&gt;&lt;asp:image ID=&#34;Image2&#34; runat=&#34;server&#34; src=&#39;&lt;%#getSRCfuser(Container.DataItem)%&gt;&#39; CssClass=&#34;media-object img-rounded animated fadeInDown&#34; Width=&#34;45px&#34; Height=&#34;45px&#34; data-toggle=&#34;tooltip&#34; title=&#34;Profile Photo&#34; alt=&#34;&#34; /&gt; &lt;/a&gt; &lt;div class=&#34;media-body&#34; style=&#34;margin-bottom:2px&#34;&gt; &lt;h5 class=&#34;&#34; style=&#34;margin-bottom:2px;margin-top:2px &#34;&gt; &lt;a class=&#34;pull-left&#34; href=&#39;&lt;%#getUserHREF1(Container.DataItem)%&gt;&#39;&gt; &lt;asp:Label ID=&#34;lblfname&#34; runat=&#34;server&#34; Text=&#39;&lt;%#DataBinder.Eval(Container.DataItem,&#34;Name&#34;) %&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;#666666&#34; Font-Size=&#34;Larger&#34; /&gt; &lt;asp:Label ID=&#34;lblModalId&#34; runat=&#34;server&#34; Text=&#39;&lt;%#Eval(&#34;Id&#34;) %&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;&#34; Font-Size=&#34;&#34; Visible=&#34;False&#34; /&gt; &lt;asp:Label ID=&#34;lblfUserName&#34; runat=&#34;server&#34; Text=&#39;&lt;%#Eval(&#34;FriendUserName&#34;) %&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;&#34; Font-Size=&#34;&#34; Visible=&#34;False&#34; /&gt; &lt;asp:Label ID=&#34;lblUserName&#34; runat=&#34;server&#34; Text=&#39;&lt;%#Eval(&#34;UserName&#34;) %&gt;&#39; Font-Bold=&#34;True &#34; ForeColor=&#34;&#34; Font-Size=&#34;&#34; Visible=&#34;False&#34; /&gt; &lt;asp:Label ID=&#34;Label7&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-check-circle verified-color&#34; data-toggle=&#34;tooltip&#34; title=&#34;&#34; data-original-title=&#34;Verified Account&#34;&gt;&lt;/asp:Label&gt;&lt;/a&gt;&lt;div class=&#34;clearfix&#34; &gt;&lt;/div&gt; &lt;i style=&#34;margin-right:2px; margin-left:2px; color:Silver; &#34; class=&#34;fa fa-clock-o&#34;&gt;&lt;/i&gt; &lt;asp:Label ID=&#34;Label25&#34; runat=&#34;server&#34; Text=&#39;&lt;%# DataBinder.Eval(Container.DataItem, &#34;SendDate&#34;,&#34;{0:MMM dd,yyyy}&#34; ) %&gt;&#39; Font-Size=&#34;Smaller&#34; ForeColor=&#34;Gray&#34; /&gt; &lt;a class=&#34;&#34; href=&#39;&lt;%#getUserHREF1(Container.DataItem)%&gt;&#39; style=&#34;margin-left:2px;&#34;&gt; &lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt; &lt;asp:Label ID=&#34;Label28&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-star&#34; ForeColor=&#34;gold&#34; Font-Size=&#34;Small&#34;&gt;&lt;/asp:Label&gt;&lt;asp:Label ID=&#34;Label29&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-star-half&#34; ForeColor=&#34;gold&#34; Font-Size=&#34;Small&#34;&gt;&lt;/asp:Label&gt;&lt;asp:Label ID=&#34;Label30&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-star-half&#34; ForeColor=&#34;gold&#34; Font-Size=&#34;Small&#34;&gt;&lt;/asp:Label&gt;&lt;asp:Label ID=&#34;Label31&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-star-o&#34; ForeColor=&#34;gold&#34; Font-Size=&#34;Small&#34;&gt;&lt;/asp:Label&gt;&lt;asp:Label ID=&#34;Label32&#34; runat=&#34;server&#34; CssClass=&#34;fa fa-star-o&#34; ForeColor=&#34;gold&#34; Font-Size=&#34;Small&#34;&gt;&lt;/asp:Label&gt;&lt;/a&gt;&lt;br /&gt;&lt;div class=&#34;clearfix&#34; &gt;&lt;/div&gt; &lt;/h5&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;a class=&#34;&#34; href=&#39;&lt;%#getUserHREF05(Container.DataItem)%&gt;&#39;&gt; &lt;h4 style=&#34;margin-bottom:4px&#34;&gt; &lt;/h4&gt; &lt;asp:Label ID=&#34;lblpost&#34; runat=&#34;server&#34; Text=&#39;&lt;%# Eval(&#34;ContentPost&#34;).ToString().Length &gt;180 ? Eval(&#34;ContentPost&#34;).ToString().Substring(0,180)+&#34;...(Read More)&#34; : Eval(&#34;ContentPost&#34;).ToString()%&gt;&#39; Font-Names=&#34;Comic Sans MS&#34; Font-Bold=&#34;False&#34; Font-Strikeout=&#34;False&#34; ForeColor=&#34;#333333&#34;&gt; &lt;/asp:Label&gt;&lt;/a&gt;&lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt; &lt;a class=&#34;&#34; href=&#39;&lt;%#getUserHREF05(Container.DataItem)%&gt;&#39;&gt; &lt;asp:Image ID=&#34;Image1&#34; runat=&#34;server&#34; src=&#39;&lt;%#getSRCDD(Container.DataItem)%&gt; &#39; class=&#34;&#34; style=&#34; width:30% &#34; alt=&#34;&#34; data-aria-label-part=&#34;&#34; /&gt; &lt;span class=&#34;icon-focus&#34;&gt;&lt;/span&gt; &lt;/a&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;!--/.direct-chat-messages--&gt;&lt;!-- Contacts are loaded here --&gt;&lt;/div&gt;&lt;!-- /.box-body --&gt;&lt;div class=&#34;col-sm-12&#34;&gt; &lt;div id=&#34;&#34; class=&#34;&#34;&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:FormView&gt; &lt;/ContentTemplate&gt; &lt;triggers&gt; &lt;asp:PostBackTrigger ControlID=&#34;GetMergedAll&#34; /&gt; &lt;/triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;div class=&#34;clearfix&#34;&gt;&lt;/div&gt; &lt;div class=&#34;modal-footer&#34;&gt; &lt;asp:LinkButton ID=&#34;btnSharenow&#34; runat=&#34;server&#34; CssClass=&#34; btn-twitter btn-lg&#34; BorderColor=&#34;#003399&#34; OnClick=&#34;btnSharenow_Click&#34; &gt; &lt;asp:Label ID=&#34;Label26&#34; runat=&#34;server&#34; Text=&#34;&#34; CssClass=&#34; fa fa-rotate-right&#34; Font-Size=&#34;X-Large&#34;&gt;&lt;/asp:Label&gt; &lt;i style=&#34;margin-left:1px&#34;&gt;&lt;/i&gt; &lt;asp:Label ID=&#34;Label27&#34; runat=&#34;server&#34; Text=&#34;Pass Now&#34; Font-Size=&#34;Medium&#34; Font-Bold=&#34;True&#34;&gt;&lt;/asp:Label&gt; &lt;/asp:LinkButton&gt;&lt;/div&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;!-- Trigger the modal with a button --&gt;&lt;!-- Modal share category --&gt; </pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 20 Dec 2016 00:58:46 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>Hi <a class="username" rel="micah"> micah</a>,</p> <p>Image "src" replace with "ImageUrl".Please refer the below code.</p> <p>&nbsp;<span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">&lt;asp:Image ID=&#34;Image2&#34; runat=&#34;server&#34; src=&#39;&lt;%#getSRCfuser(Container.DataItem)%&gt;&#39; CssClass=&#34;media-object img-rounded animated fadeInDown&#34; Width=&#34;45px&#34; Height=&#34;45px&#34; data-toggle=&#34;tooltip&#34; title=&#34;Profile Photo&#34; alt=&#34;&#34; /&gt;</pre> <p>Replace above code with below.</p> <pre class="brush: csharp">&lt;asp:Image ID=&#34;Image2&#34; runat=&#34;server&#34; ImageUrl=&#39;&lt;%#getSRCfuser(Container.DataItem)%&gt;&#39; CssClass=&#34;media-object img-rounded animated fadeInDown&#34; Width=&#34;45px&#34; Height=&#34;45px&#34; data-toggle=&#34;tooltip&#34; title=&#34;Profile Photo&#34; alt=&#34;&#34; /&gt;</pre> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Tue, 20 Dec 2016 09:31:25 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>i tried it but its inserting this into the ImageName column</p> <p>&nbsp;</p> <pre class="brush: sql">/PROFILEPHOTOS/comlogo.jpg</pre> <p>instead of</p> <p>&nbsp;</p> <p>comlogo.jpg</p> <p>The path has been provided on the code already</p> <p>&nbsp;</p> <pre class="brush: csharp"> public string getSRCfuser(object imgSRC) { DataRowView dRView = (DataRowView)imgSRC; string ImageName = dRView[&#34;ImageName3&#34;].ToString(); // string myComments = dRView[&#34;MyComments&#34;].ToString(); if (ImageName == &#34;NoImage&#34;) { return ResolveUrl(&#34;~/Site_Images/image_missing.JPG&#34;); } else { return ResolveUrl(&#34;~/PROFILEPHOTOS/&#34; + dRView[&#34;ImageName3&#34;].ToString()); } } </pre> <p>So your example is not showing image because of the path you added on the image control</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 02:15:19 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>Hi <a class="username" rel="micah">micah</a>,</p> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">string img = (SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl; string img2 = (SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl;</pre> <p>Replace above code with below.</p> <pre class="brush: csharp">string img = (SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[2]; string img2 = (SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[2];</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 02:47:03 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>error</p> <p>&nbsp;</p> <pre class="brush: csharp">Server Error in &#39;/&#39; Application. Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array. Source Error: Line 102: string comment = (SharePost.Row.FindControl(&#34;txtcommentshare&#34;) as TextBox).Text; Line 103: string img = (SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[2]; Line 104: string img2 = (SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[2]; Line 105: string fname = (SharePost.Row.FindControl(&#34;lblfname&#34;) as Label).Text; Line 106:</pre> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 02:58:51 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>Hi <a class="username" rel="micah">micah</a>,</p> <p>Put debugger in your code.check "ImageURL" path and split the ('/') and assign the image name and index of splitting values start from zero so you need to cross check exactly where your image name is present.</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 03:19:03 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>still inserting the name of the image folder into table instead of the imagename</p> <p>here is the image path</p> <p><a href="http://localhost:4463/UserImage/">http://localhost:4463/UserImage/</a></p> <p>&nbsp;</p> <p>but this is what is inserted</p> <p>UserImage</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 07:47:25 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<blockquote><cite>micah says:</cite> <pre>http://localhost:4463/UserImage/</pre> </blockquote> <p>This is not the valid image path. So first pass the proper image path and replace the below code</p> <pre class="brush: csharp">string img = (SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[2]; string img2 = (SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[2];</pre> <p>&nbsp;With</p> <pre class="brush: csharp">string img = (SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[(SharePost.Row.FindControl(&#34;Image2&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;).Length - 1]; string img2 = (SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;)[(SharePost.Row.FindControl(&#34;Image1&#34;) as System.Web.UI.WebControls.Image).ImageUrl.Split(&#39;/&#39;).Length - 1];</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 08:57:12 GMTGet image name from image Path from FormView and save in Database using C# in ASP.Net<p>Thank you so much for your help, this very last solution worked.</p>http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/http://www.aspforums.net/Threads/556508/Get-image-name-from-image-Path-from-FormView-and-save-in-Database-using-C-in-ASPNet/Wed, 21 Dec 2016 09:33:15 GMT