【问题标题】:get data from Db Column and make it Proper URl?从 Db 列获取数据并使其成为正确的 URl?
【发布时间】:2014-05-13 04:16:17
【问题描述】:

我有一列包含多个 URL,由“,”分开,我想正确获取这些 URL,并在我的 asp.net 页面中的 J 查询滑块中显示。

列详细信息如 “ID”、“网址” 1、www.abc.com/abc.jpg、www.bcd.com/ced.jpeg、 一个单列值中有很多图像 URL。

需要您的建议

【问题讨论】:

  • 获取列值并使用','分割并访问它
  • string[] url=urldatabasecolumn.Split(',');
  • 谢谢你们,我已经完成了先拆分我的数组,然后制作了正确的 URl .. 谢谢你们的反馈。
  • 包含逗号的 URL 怎么办?这是允许的,并且会破坏你正在尝试做的事情。

标签: c# jquery asp.net sql vb.net


【解决方案1】:
string sPhotoURL = Convert.ToString(dt.Rows[0]["PHOTO_LOCATIONColumnName"]);
string[] words = sPhotoURL.Split(',');
int count = 0;
hdnImageCount.Value = words.Length.ToString();
foreach (string word in words)
{
    if (word.Length > 50)
    {
        count += 1;
        String correctURl = word.Substring(45);
        string photoNumber = correctURl.Substring(1, 2);
        correctURl = "http://" + "images-+photoNumber+urlsomething/something/"+correctURl;
        string url = correctURl;
    }
}

这将使我的 URl 正确,然后我将其传递给函数以下载图像。

谢谢大家,我通过以下代码完成了这一切......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-11
    • 2019-04-09
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多