Home » Archive by category "Applications" (Page 5)

Archive for the 'Applications' Category

Content Limited by Character Number – VB.NET

Code behind Partial Class _default Inherits System.Web.UI.Page Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then ‘character count If DataBinder.Eval(e.Row.DataItem, “description”).ToString.Length >= 175 Then e.Row.Cells(3).Text = + DataBinder.Eval(e.Row.DataItem, “description”).ToString.Substring(0, 175) + e.Row.Cells(3).ToolTip = DataBinder.Eval(e.Row.DataItem, “description”).ToString Else e.Row.Cells(3).Text = + DataBinder.Eval(e.Row.DataItem, “description”).ToString End If End If End Sub End Class

Add item on the dropdownlist – VB.NET

Markup page <!– ‘define control –> <asp:DropDownList ID=”MySelectionDDL” runat=”server” AutoPostBack=”True” AppendDataBoundItems=”true” DataSourceID=”MySelectionDS” DataTextField=”Text” DataValueField=”Value” OnDataBound=”MySelectionDDL_DataBound”> <!– ‘define datasource –> <asp:SqlDataSource ID=”MySelectionDS” runat=”server” ConnectionString=”< %$ ConnectionStrings:my_sql_connection %>” SelectCommand=”SELECT [Text], [Value] FROM [MyTable] ORDER BY [Text]”> </asp:SqlDataSource> Code behind Protected Sub MySelectionDDLDataBound(ByVal sender As Object, ByVal e As EventArgs) ‘add item at the beginning of the list […]

Refresh page on button click

Markup page <script runat=”server”> Sub UpdateMessage(ByVal source As Object, ByVal e As SqlDataSourceStatusEventArgs) If e.AffectedRows > 0 Then ‘ Perform any additional processing, ‘ such as setting a status label after the operation. Page.Response.Redirect(Page.Request.Url.ToString(), True) End If End Sub ‘UpdateMessage </script> <asp:SqlDataSource ID=”ImgEditDS4″ runat=”server” ConnectionString=”< %$ ConnectionStrings:MyConnStr %>” SelectCommand=”SELECT [photo_id], [photo_1] WHERE ([photo_id] = @p_id)” […]