How to replace <p> </p> in gridview rows in asp.net c# <asp:TemplateField HeaderText="Questions" SortExpression="TheQuestion"> <ItemTemplate> <asp:Label ID="lblQuestion" runat="server" Text='<%# Server.HtmlDecode(Eval("TheQuestion").ToString()) %>'></asp:Label> </ItemTemplate> <ItemStyle HorizontalAlign="Left" Width="100%" /> </asp:TemplateField>
Posts
Showing posts from 2013
- Get link
- X
- Other Apps
Gridview export to excel without having control like linkbutton, or anybutton(to hide columns) Frontend note: <%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="CarMake.aspx.cs" Inherits="admin_CarMake" EnableEventValidation="false" %> ----------------------------------------------------------------------------------------- Backend cs:- protected void btnExport_Click(object sender, EventArgs e) { ExporttoExcel(); } public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ } private void ExporttoExcel() { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=ExistingCarData" + System.DateTime.Now.ToShortDateString() + ".xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; Str...
- Get link
- X
- Other Apps
update multiple columns into single or one columns in sql begin tran CREATE TABLE #TempAdd ( DealerId int, MainAddress varchar(1000) ) insert into #TempAdd SELECT DealerId , DealerName + '<br/>' + CASE WHEN Address1 is null THEN '' ELSE Address1 +' <br/>' END + CASE WHEN Address2 is null THEN '' ELSE Address2 +' <br/>' END + CASE WHEN Address3 is null THEN '' ELSE Address3 +' <br/>' END + CASE WHEN Address is null THEN '' ...
- Get link
- X
- Other Apps
Preview image file before upload to webserver Ref: http://blog.raminassar.com/2011/07/05/preview-image-file-before-upload-to-webserver/#.UZcVs6JHLRJ Muddsar Khan http://www.aspsnippets.com/Articles/Display-image-after-upload-without-page-refresh-or-postback-using-ASP.Net-AsyncFileUpload-Control.aspx You can use javascript to preview the selected image before uploading it to the server. < html xmlns ="http://www.w3.org/1999/xhtml" > < head id ="Head1" runat ="server" > < title > Main Page </ title > < script type ="text/javascript" > function FileUpload1_onchange(oFileUpload1) { document.getElementById( 'Image1' ).src = oFileUpload1.value ; } </ script > </ head > < body > < form id ="form1" runat ="server" > < asp:FileUpload ...
- Get link
- X
- Other Apps
Code to add background color or background image:- Frontend:- <html> <head> <title></title> </head> <body id="bgBody" runat="server"> </body> </html> C# apply in any method:- // Background color code bgBody.Attributes["bgcolor"] = "#cc0000"; //background image code bgBody.Attributes.Add("background", "images/fullbg.jpg");
- Get link
- X
- Other Apps
How to insert multiple rows from c# table to sql database table:- Frontend: <asp:Button ID="Button2" runat="server" Text="Create Table" onclick="Button2_Click" /> <asp:GridView ID="gveg" runat="server"> </asp:GridView> Backend C#: protected void Button2_Click(object sender, EventArgs e) { // // Here we create a DataTable with four columns. // DataTable temptable = new DataTable(); temptable.Columns.Add("ProductID", typeof(string)); temptable.Columns.Add("RelatedProductID", typeof(string)); ...
- Get link
- X
- Other Apps
Comparing a value in between two columns I have a table TblControl. Data type of both field is int. StartRange End Range BMIClassification Table startval endvalue 0 100 200 300 500 600 900 950 SELECT StartRange, EndRange FROM Control WHERE 225 BETWEEN StartRange AND EndRange eg:- Declare @BMIValue int set @BMIValue=34 SELECT * FROM BMIClassification WHERE @BMIValue between startval and endvalue
- Get link
- X
- Other Apps
insert, update ,delete multiple rows using c# and sql at once with the help of list and function ANS. 1. Create function:- CREATE FUNCTION [dbo].[udf_CsvToInt] ( @Array VARCHAR(max) ) RETURNS @IntTable TABLE (IntValue INT) AS BEGIN IF @Array <> '' BEGIN DECLARE @separator char(1) SET @separator = ',' DECLARE @separator_position INT DECLARE @array_value VARCHAR(2000) SET @array = @array + ',' WHILE patindex('%,%' , @array) <> 0 BEGIN SELECT @separator_position = patindex('%,%' , @array) SELECT @array_value = LEFT(@array, @separator_position - 1) INSERT @IntTable Values (CAST(@array_value AS INT)) SELECT @array = stuff(@array, 1, @separator_position, '') END END RETURN end 2.update example ALTER PROC spUpdateTable @strID varchar(100) AS UPDATE tablename SET IsActive = 1 WHERE tableID in (select * from dbo.udf_CsvToInt(@strID) ) 3. C# button Click event protected void btnTagIndexPage_Click(object sender, Event...