c# - Customize SqlDataSource to store part of string -


i'm using updatepanel in asp.net webforms upload image. set image.imageurl full virtual path image (/images/news/filenname.jpg), want save filename in database (filename.jpg). how customize sqldatasource take part of url?

<asp:sqldatasource    id="sqldatasourcenews"    runat="server"    connectionstring="<%$ connectionstrings:connectionstring %>"    updatecommand="update [foo] set [pic] = @pic [id] = @id">    <updateparameters>       <asp:parameter name="pic" type="string" />    </updateparameters>    <insertparameters>       <asp:parameter name="pic" type="string" />     </insertparameters>  </asp:sqldatasource> 

you can set update parameters on page_load , use substring function file name full url:

protected void buton_click(object sender, eventargs e) {         sqldatasource1.updateparameters["pic"].defaultvalue = "string fetched substring method";         sqldatasource1.update(); } 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -