1
Answer

how to get marque text ID from database

Imran Pervez

Imran Pervez

14y
2.7k
1
Dear all
I use a custom control for display news on my web application with marquee option
marquee data is show from database.

my issue is that......when click on marquee item how i get clicked item ID from database for transferring acording to clicked news page

data tabel=menuset
data field is= ID ,item,url

 my code is

 dbClasses.clsSqlConnection objclsSqlConnection = new MPOWER.dbClasses.clsSqlConnection();
        DataSet menuset = new DataSet();
        protected void Page_Load(object sender, EventArgs e)
        {
            menuset = objclsSqlConnection.GetDataSet((string)ConfigurationSettings.AppSettings["sConnectionString1"], "Select * from MainMenu");
            if (menuset.Tables.Count > 0)
            {
                Datalist2.DataSource = menuset;
                Datalist2.DataBind();
            }
        
        }

--------------------------
<tr>
        <td class="style42" style="font-size: small; font-style: normal;">
             <marquee  onmouseover="this.stop();" behavior="Scroll" direction="up" 
                 scrolldelay="250" onmouseout="this.start();" style="height: 101px">
            <asp:DataList ID="Datalist2" runat="server" cellspacing="0" ForeColor="White"
                 >
           
                      
                <ItemTemplate>
              
                    <asp:HyperLink ID="Hyperlink1" runat="server"
                   
                        />
                    &nbsp; <a href='<%# DataBinder.Eval(Container.DataItem,"Url") %>'>
                        <%# DataBinder.Eval(Container.DataItem,"Title") %>
                    </a>
                   
                </ItemTemplate>
             
            </asp:DataList></marquee>
        </td>
    </tr>



----------------

i am waiting for solution
thanks in advance
Answers (1)
1
Marjan Venema

Marjan Venema

NA 56 0 9y
Ah, hmm, then you are in a bit of a pickle. That is much harder.

You could try replacing any {0} (and {1}, {2}) with some RegEx and then trying to match the string you get at run time against that.

For example:

        Boolean AreEqual(string template, string text)
        {
            string regexed = template.Replace("{0}", ".*");
            regexed = template.Replace("{1}", ".*");
            regexed = template.Replace("{2}", ".*");

            Regex regex = new Regex(regexed);
            return regex.IsMatch(text);

        }

Please note, my RegEx skills are below par. And of course you would want to replace the replacements at the top with something more intelligent.

Cheers, Marjan
Accepted
1
Marjan Venema

Marjan Venema

NA 56 0 9y
If you have the value(s) of the arguments at runtime as well, then you could do something like: 

        Boolean Matches(string runTimeFullString, string runTimeArgument)
        {
            string FromDatabase = "The Cow is {0}";
            return runTimeFullString.Equals(string.Format(FromDatabase, runTimeArgument));
        }

If that doesn't help, could you please clarify what you are trying to achieve and what pieces of information you have to work with?
0
Murugesh P

Murugesh P

NA 179 5.7k 9y
Hi Marjan, Thanks for your response. Basically i have to compare two strings one from Resource file another from Databse. Ex: In Resource: The cow is {0} In Data Base: The cow is {0} But during run time the Parameter {0} will be filled and it becomes "The cow is white". So comparing The cow is {0} and The cow is White will be marked as difference. And Data base will not have run time parameters. So Basically i need to compare the strings without the Parameter {0}.
0
Abhineet Srivastava

Abhineet Srivastava

NA 1.1k 62.7k 9y
String.compare(s1,s2)
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 9y
using String.Compare method.