Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On the MS IBuySpy Portal the an

Status
Not open for further replies.

oddball

Technical User
Mar 17, 2000
64
0
0
GB


On the MS IBuySpy Portal the announcement and event modules use datalists to display entries in the
corresponding DB tables. What i would like to achieve is that the data list will only show the first 100 characters or first 20 words (preferably) from the description column. I'll then create a link to a page that will display the full description listing from the table for the given entry. Does the ItemTemplate allow you to do such formating?

My other alternative is to add a colum to each table called DescriptionShort
where the user defines their own shortened soundbite from the main description entry. Would rather do it the first way though.

any thoughts?

cheers,

si
 
Crop the string of the description before you display it to begin.

In the item editor define a button or link that will take the user to another page Use custom databinding to send the id of the record as a query string. In this new page do a lookup on that id and display the full description.

Hope this helps. [peace]
 
This is the function that gets the data and returns it to the datalist in the event module. How do i crop the description string (called Description). Can i crop it after the 'myCommand.Fill(myDataSet)' whilst it is in the Dataset, if so how?


'*********************************************************************
'
' GetEvents Method
'
' The GetEvents method returns a DataSet containing all of the
' events for a specific portal module from the events
' database.
'
' NOTE: A DataSet is returned from this method to allow this method to support
' both desktop and mobile Web UI.
'
' Other relevant sources:
' + <a href=&quot;GetEvents.htm&quot; style=&quot;color:green&quot;>GetEvents Stored Procedure</a>
'
'*********************************************************************

Public Function GetEvents(ByVal moduleId As Integer) As DataSet

' Create Instance of Connection and Command Object
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings(&quot;connectionString&quot;))
Dim myCommand As New SqlDataAdapter(&quot;GetEvents&quot;, myConnection)

' Mark the Command as a SPROC
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC
Dim parameterModuleId As New SqlParameter(&quot;@ModuleId&quot;, SqlDbType.Int, 4)
parameterModuleId.Value = moduleId
myCommand.SelectCommand.Parameters.Add(parameterModuleId)

' Create and Fill the DataSet
Dim myDataSet As New DataSet()
myCommand.Fill(myDataSet)

' Return the DataSet
Return myDataSet

End Function



cheers,

si
 
aha I think I have it.
I am not sure about croping the string from the dataset but you can do it when you assign the string to a text box or some other control in your datalist. I am not sure about the 20 words bit though I am sure you could do a search on the first 20 spaces then truncate the string after that.

Anyway add this code replacing my names with your own of course to the databinding property of your control that is to display the description.

Mid(DataBinder.Eval(Container, &quot;DataItem.desc&quot;), 1, 100)


The 1 specifies to start at the beggining of the string and the 100 says to count 100 chars in.

If you want to type this in the html editor then use this code

<asp:TextBox id=TextBox1 runat=&quot;server&quot; Text='<%# Mid(DataBinder.Eval(Container, &quot;DataItem.desc&quot;), 1, 100) %>'>


Hope this helps you [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top