Function calling from client side
-
Hey... I have data bound to a DataList and I can access any column of it by going <%# DataBinder.Eval(Container.DataItem, "Description")%> in the html code. My problem is the data is to long and I want to trim it to 40 characters or less. So I wrote a function to do so. public void Description() { string sDescription = string sTemp = string.Empty; for (int i=0;i<40;i++) sTemp += sDescription[i]; sTemp += "..."; Response.Write(sTemp); } now how do I pass in the description string????? you can't use <% %> inside a scripted function???? Can anyone help me or if anyone has a better way of doing this I would love to hear it!! Thanks, Steve Nelson
-
Hey... I have data bound to a DataList and I can access any column of it by going <%# DataBinder.Eval(Container.DataItem, "Description")%> in the html code. My problem is the data is to long and I want to trim it to 40 characters or less. So I wrote a function to do so. public void Description() { string sDescription = string sTemp = string.Empty; for (int i=0;i<40;i++) sTemp += sDescription[i]; sTemp += "..."; Response.Write(sTemp); } now how do I pass in the description string????? you can't use <% %> inside a scripted function???? Can anyone help me or if anyone has a better way of doing this I would love to hear it!! Thanks, Steve Nelson
You could probably use <%= myField %>, but it's probably better to use Data Formatting in the DataBind. ie. <%# DataBinder.Eval(Container.DataItem, "Description")%> becomes <%# DataBinder.Eval(Container.DataItem, "Description", "{0,40}")%> (I think I have that right, I'm working from memory, but it should lead you in the right direction if it's not quite there) Paul We all will feed the worms and trees
So don't be shy - Queens of the Stone Age, Mosquito Song