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
Content Limited by Character Number – VB.NET
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 behindProtected Sub MySelectionDDLDataBound(ByVal sender As Object, ByVal e As EventArgs) 'add item at the beginning of the list MySelectionDDL.Items.Insert(0, New ListItem("Please Select", "")) 'add item at the end of the list (assuming there are 10 records on the list) MySelectionDDL.Items.Insert(11, New ListItem("Other", "Other")) End Sub
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)" UpdateCommand="UPDATE [MyTable] SET [photo_1] = @photo_1 WHERE [photo_id] = @f_id" OnUpdated="UpdateMessage" > <SelectParameters> <asp:QueryStringParameter Name="p_id" QueryStringField="aid" Type="Int32" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="photo_1" Type="String" /> <asp:Parameter Name="p_id" Type="Int32" /> </UpdateParameters> </asp:SqlDataSource>