tsql rename table and column
--rename a table:
EXEC sp_rename 'OldTableName', 'NewTableName'
--rename a column:
EXEC sp_rename
@objname = 'TableName.OldColumnName',
@newname = 'NewColumnName',
@objtype = 'COLUMN'
Achievement provides the only real pleasure in life
--rename a table:
EXEC sp_rename 'OldTableName', 'NewTableName'
--rename a column:
EXEC sp_rename
@objname = 'TableName.OldColumnName',
@newname = 'NewColumnName',
@objtype = 'COLUMN'
Posted by
SF
at
10:12 am
0
comments
Class1 obj= new Class1();
string propertyName = "name1";
string objValue = "";
Type type = obj.GetType();
PropertyInfo prop = type.GetProperty(propertyName );
prop.SetValue(obj, objValue , null);
Posted by
SF
at
2:20 pm
0
comments
string text1 = this.Server.MapPath("~/" + [FileFolder]);
if (Directory.Exists(text1))
{
string text2 = text1 + @"\[File Name with extension]";
if (System.IO.File.Exists(text2))
{
FileStream stream1 = new FileStream(text2, FileMode.Open, FileAccess.Read);
byte[] buffer1 = new byte[((int)stream1.Length) + 1];
stream1.Read(buffer1, 0, (int)stream1.Length);
stream1.Close();
//Writes the file out the Response object
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment;filename=\"[File Name with extension]\";");
Response.WriteFile(text2, true);
Response.ContentType = "application/x-zip-compressed";
Response.BinaryWrite(buffer1);
Response.End();
}
}
Posted by
SF
at
10:34 am
0
comments
http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx
Posted by
SF
at
10:49 am
0
comments
found this helpful
http://visualstudiohacks.com/general/confessions-of-a-keyboard-junkie/
Posted by
SF
at
11:14 am
0
comments
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + RadUpload.UploadedFiles[0].FileName+";" +
"Extended Properties=Excel 8.0;";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand cmdSelectAdditions = new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
OleDbDataAdapter AdapterForAdditions = new OleDbDataAdapter();
AdapterForAdditions.SelectCommand = cmdSelectAdditions;
DataSet dsAdditions = new DataSet();
AdapterForAdditions.Fill(dsAdditions);
objConn.Close();
Posted by
SF
at
4:16 pm
0
comments
this article helped me, hope it helps you too!
http://www.4guysfromrolla.com/articles/030911-1.aspx
I need to parse HTML into the pdf, the implementation is:
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Transactions.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Document document = new Document(PageSize.A1, 10f, 10f, 10f, 0f);
PdfWriter.GetInstance(document, Response.OutputStream);
// Open the Document for writing
document.Open();
string documentContent = string.Empty;
document.NewPage();
documentContent = "Confirmation" + "
" + body;
StringReader sr = new StringReader(documentContent);
foreach (object item in HTMLWorker.ParseToList(sr, null).ToList())
{
document.Add((IElement)item);
}
document.Close();
Response.Write(document);
Response.End();
Posted by
SF
at
2:18 pm
0
comments
found this article very helpful
http://support.microsoft.com/kb/306572/
I modified it a bit to work for me (I am using RadUpload to get the file):
// Create connection string variable. Modify the "Data Source"
// parameter as appropriate for your environment.
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + ruImporter.UploadedFiles[0].FileName+";" +
"Extended Properties=Excel 8.0;";
// Create connection object by using the preceding connection string.
OleDbConnection objConn = new OleDbConnection(sConnectionString);
// Open connection with the database.
objConn.Open();
// The code to follow uses a SQL SELECT command to display the data from the worksheet.
// Create new OleDbCommand to return data from worksheet.
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [Sheet1$]", objConn);
// Create new OleDbDataAdapter that is used to build a DataSet
// based on the preceding SQL SELECT statement.
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
// Pass the Select command to the adapter.
objAdapter1.SelectCommand = objCmdSelect;
// Create new DataSet to hold information from the worksheet.
DataSet objDataset1 = new DataSet();
// Fill the DataSet with the information from the worksheet.
objAdapter1.Fill(objDataset1);
// Clean up objects.
objConn.Close();
Posted by
SF
at
10:09 am
0
comments
this script only works with combination of firstname+' '+lastname.
--firstname
SUBSTRING(fullname, 1, CHARINDEX(' ', fullname) - 1) as firstname
--lastname
SUBSTRING(fullname, CHARINDEX(' ', fullname) + 1, LEN(fullname)) as lastname
Posted by
SF
at
12:16 pm
1 comments
thanks to many similar sources on the web, I came up with my script, it splits up a comma seperated string into a table with duplicate records removed
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Spliter]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].Spliter
GO
CREATE FUNCTION Spliter(@String varchar(max), @Delimiter char(1))
returns @temptable TABLE (items varchar(max))
as
begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String
if(len(@slice)>0 and (select count(items) from @temptable where items = @slice)=0)
insert into @temptable(Items) values(@slice)
set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end
return
end
GO
SELECT i.items FROM dbo.Spliter(@tempstring,',') AS i where items not in (select comparesource from comparesourcetable)
Posted by
SF
at
11:09 am
0
comments
found these properties quite handy when you want to give end user limited access when designing the report in web browser, especially when you want to hide the connection string credentials.
StiWebDesignerOptions.Dictionary.AllowModifyDictionary = true;
StiWebDesignerOptions.Dictionary.AllowModifyConnections = false;
StiWebDesignerOptions.Dictionary.ShowConnectionType = false;
StiWebDesignerOptions.Dictionary.AllowModifyDataSources = false;
StiWebDesignerOptions.Dictionary.AllowModifyVariables = true;
just put them before swdCustomReport.Design(report); in your code
Posted by
SF
at
11:33 am
1 comments
I got this message:
Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-cretead.
the solution is:
Tools > Options > Designers > Table and Database Designers
unselect 'Prevent saving changes that require the table to be re-created' check box
Posted by
SF
at
10:07 am
0
comments
var rtbName = $find("<%= rtbName.ClientID %>");
rtbName.set_value('Hello World');
Posted by
SF
at
12:05 pm
0
comments
SUBSTRING([TheString], patindex('%[^0]%',[TheString]), 10)
Posted by
SF
at
11:44 am
0
comments
public static Color FindeOppositeColor(Color InputColour)
{
return Color.FromArgb(255 - InputColour.R, 255 - InputColour.G, 255 - InputColour.B);
}
Posted by
SF
at
1:02 pm
0
comments
sometimes i need to open radwindow from server side, I use this code snippet from Telerik:
protected void Button1_Click(object sender, EventArgs e)
{
Telerik.WebControls.RadWindow newwindow = new Telerik.WebControls.RadWindow();
newwindow.ID = "RadWindow1";
newwindow.NavigateUrl = "http://www.google.com";
newwindow.VisibleOnPageLoad = true;
RadWindowManager1.Windows.Add(newwindow);
}
newwindow.Width = Unit.Pixel(500);
newwindow.Height = Unit.Pixel(500);
newwindow.Behaviors = WindowBehaviors.Move | WindowBehaviors.Close;
Posted by
SF
at
7:45 pm
0
comments
what a frustrating 5 minutes....
try Windows key + Up key
enjoy
Posted by
SF
at
3:05 pm
0
comments
oldPath and newPath should look like "c:/FolderABC" or "~/FolderABC"
System.IO.Directory.Move(@oldPath, @newPath);
Posted by
SF
at
5:38 pm
0
comments
found this useful to keep necessary usage of disk space with sql db installed
USE myDatabase
GO
DBCC SHRINKFILE(myDatabase_log, 1)
BACKUP LOG myDatabase WITH TRUNCATE_ONLY
DBCC SHRINKFILE(myDatabase_log, 1)
Posted by
SF
at
11:16 am
0
comments
found the solution at:
http://www.telerik.com/community/forums/aspnet-ajax/editor/incorrect-rendering-of-radeditor-when-shown-with-ajax-in-initially-hidden-parent.aspx
Posted by
SF
at
11:14 am
0
comments
when I enter a random text instead of an integer into the filter, and select any option in the filter options dropdown, i get error
the solution is kind of tricky:
EnableLinqExpressioins property of grid as false
Posted by
SF
at
5:28 pm
0
comments
in my radgrid i use template as EditFormType. When I open the edit form for a grid item I want to show or hide a texbos based on the value populated in it. It can be achieved this way:
Protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
TextBox TextBox1 = (TextBox)item.FindControl("TextBox1");
//OR/// TextBox txtbox = (TextBox)item["TextBox1"].Controls[0];
if (TextBox1.Text == "your value")
{
TextBox1.Visible = false;
}
}
}
Posted by
SF
at
1:30 pm
0
comments
I use the following line in code behind to open a radwindow:
During as soon as I opened the window once, any postback will cause this window to popup again.
The solution is simple, just put the following code into page_load event.
RadWindow1.Visible = false;
Posted by
SF
at
8:56 am
0
comments
first, make sure you have "ClientDataKeyNames="Id" " added into the Master Table View of the radgrid
then implement the following javascript:
function OpenRecordBreakdown(Id)
{
var oWnd = radopen("RecordBreakDown.aspx?Id=" + , "rwRecordBreakDown");
oWnd.setSize(900, 600);
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Maximize + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Close)
oWnd.Center();
}
var lastClickedItem = null;
var clickCalledAfterRadprompt = false;
var clickCalledAfterRadconfirm = false;
function onClientButtonClicking(sender, args) {
if (args.get_item().get_text() == "Delete") {
if (!clickCalledAfterRadconfirm) {
args.set_cancel(true);
lastClickedItem = args.get_item();
radconfirm("Are you sure you want to delete this Item?", confirmCallbackFunction);
}
}
if (args.get_item().get_text() == "Record Breakdown") {
var cell = sender.get_element().parentNode.parentNode;
rowindex = cell.rowIndex; //The row index may vary based on the grid structure.
var grid = $find("<%=rgList.ClientID %>");
var MasterTable = grid.get_masterTableView();
var id = MasterTable.get_dataItems()[rowindex - 2].getDataKeyValue("Id");
OpenRecordBreakdown(id);
args.set_cancel(true);
}
}
function confirmCallbackFunction(args) {
if (args) {
clickCalledAfterRadconfirm = true;
lastClickedItem.click();
}
else
clickCalledAfterRadconfirm = false;
lastClickedItem = null;
}
Posted by
SF
at
10:57 am
0
comments
Found this article very useful, hope it can help you as well
Using radprompt and radconfirm with Telerik navigational controls
http://www.telerik.com/support/kb/aspnet-ajax/window/using-radprompt-and-radconfirm-with-telerik-navigational-controls.aspx
Posted by
SF
at
9:34 am
0
comments
ScriptManager.RegisterStartupScript(this, typeof(abc_def_1), "openWin", "openWin('" + ParameterId.ToString() + "');", true);
provide you still need the radwindow manager in .aspx code, and the javascript "openWin"
Posted by
SF
at
4:01 pm
0
comments
"Invalid postback or callback argument. Event validation is enabled using
in my case it is caused by trying to call a radgrid.rebind() in page_load, the radgrid sits inside of a radupdatepanel. In case of postback the code contains client script which caused this security breach. After I put radgrid.rebind() inside !IsPostBack the error disappearred.
Posted by
SF
at
10:25 am
0
comments
found this class really helpful:
http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html
Posted by
SF
at
8:52 am
0
comments
When I tried to reference a public property in user control from a container page, the intellisense doesn't seem to be able to pick up the property. Ignore the red curly underline, build the parent page, it worked~
another VS2010 bug?
Posted by
SF
at
5:19 pm
0
comments
if (e.CommandName == RadGrid.UpdateCommandName)
{
GridEditableItem editable = e.Item as GridEditableItem;
int TheId= Convert.ToInt32(editable.OwnerTableView.DataKeyValues[editable.ItemIndex]["TheId"].ToString());
Posted by
SF
at
9:36 am
0
comments
FormsAuthentication.Signout();
Response.Resirect([loginURL]);
Posted by
SF
at
10:03 am
0
comments
DECLARE @tempTable table(Id INT NOT NULL PRIMARY KEY)
DECLARE @counter INT
INSERT INTO @tempTable SELECT UserId from TestTable
SET @counter = 1
WHILE (@counter < (SELECT COUNT(UserId) FROM @tempTable)+1)
BEGIN
UPDATE TestTable SET TestColumn = '' WHERE Id = (
SELECT a.Id FROM
(SELECT Id, Row_Number() OVER(ORDER BY UserId) AS 'RN' from TestTable) as a
where a.RN = @counter
)
SET @counter = @counter + 1
END
Posted by
SF
at
10:50 am
0
comments
This is because the detail table is set to "visible=false" during the update process. Not all RadGrid controls in the application get this symptom, not sure why this happens. All you need to do is to change the setting to "visible = true"
Posted by
SF
at
10:58 am
0
comments
I came cross this this issue of failing to do a division with 2 integer values. Stupid enough......
so In order for the division to work i used CAST(value TO FLOAT)
Posted by
SF
at
9:51 am
0
comments
int tempId= 168;
RadWindow rw = rwmTEMP.Windows[0];
rw.Width = System.Web.UI.WebControls.Unit.Pixel(1000);
rw.Height = System.Web.UI.WebControls.Unit.Pixel(1000);
rw.Behaviors = WindowBehaviors.Move | WindowBehaviors.Close | WindowBehaviors.Maximize | WindowBehaviors.Resize;
rw.OpenerElementID = btnOpenWindow.ClientID;
rw.NavigateUrl = "~/xxxxx/abccc.aspx?TempId=" + tempId.ToString();
Posted by
SF
at
1:27 pm
0
comments
use the combination of &,#,10, and ; to create a new line
Posted by
SF
at
10:26 am
1 comments
the following script resets the table identity seeding to 99, the next record will have identity of 100
DBCC CHECKIDENT ("[table name]", RESEED, 99);
GO
Posted by
SF
at
1:54 pm
0
comments
use master alter database DatabaseName set offline with rollback immediate
Posted by
SF
at
2:31 pm
0
comments
update Table1
SET StartDateTime = CONVERT(datetime,
CONVERT(VARCHAR(10),StartDateTime , 101)
+' '+CONVERT(VARCHAR,datepart(HH,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(MI,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(SS,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(Ms,NewStartTime))
)
Posted by
SF
at
11:40 am
0
comments
I have 2 datetime values: StartDateTime ('11/01/2010 00:00:00') and NewStartTime('12/02/2010 09:30:00 AM'). I want to replace the time value in StartDateTime with the time value in NewStartTime. In order to achieve so I go:
DateTime NewStartDateTime = new DateTime(StartDateTime.Year, StartDateTime.Month, StartDateTime.Day, NewStartTime.Hour, NewStartTime.Minute, NewStartTime.Second);
Posted by
SF
at
3:56 pm
0
comments
this is caused by using "Request["xxx"]"
a quick fix is to use "HttpContext.Current.Request" instead
Posted by
SF
at
12:49 pm
0
comments
Update TableA
set ColumnA1 = (select a.ColumnA from
(
"SELECT" REPLACE("t.ColumnA1, t.ColumnA2", (select "ColumnB1 from TableA where ColumnB2= t.ColumnA2))
FROM TableA t
) a
where TableA.ColumnA2 = a.ColumnA2)
GO
Posted by
SF
at
6:10 pm
0
comments
RadMenu1.FindItemByText("RadMenuItem1").Visible = false;
Posted by
SF
at
9:57 am
1 comments
Edit Mode:
"if"(!RadScheduler1.StartEditingInAdvancedForm)
Insert Mode:
"if"(!RadScheduler1.StartInsertingInAdvancedForm)
Posted by
SF
at
2:50 pm
0
comments
code:
"Response".Clear();
"Response".AddHeader("content-disposition", "attachment;filename=" + FileName + ".txt");
"Response".Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
"Response".ContentType = "application/vnd.text";
"StringWriter" stringWrite = new StringWriter();
"HtmlTextWriter" htmlWrite = new HtmlTextWriter(stringWrite);
"Response".Write(strTXTFileBuilder.ToString());
"Response".End();
Error:
Internet Explorer cannot download file
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
My Solution:
Take out the line "
Posted by
SF
at
3:48 pm
0
comments
'if' not 'exists' (select .... from .... where ....)
Begin
'Insert' Into ....... (..., ..., ...) values (..., ..., ...,)
END
Posted by
SF
at
2:26 pm
0
comments
in the Parent page add into the radwinow aspx code:
sas"<"telerik:radwindow id="rwpopup111" title="popup111" runat="server" behaviors="Close" onclientclose="OnClientClose" navigateurl="popup111.aspx">
also add javascript:
function OnClientClose(oWnd)
{
//place your code to execute, see below for my examples, in this example I rebind a grid:
var hf111 = document.getElementById("");
var masterTable1 = $find("").get_masterTableView();
masterTable1.rebind();
var masterTable = $find("").get_masterTableView();
masterTable.rebind();
//after radwindow close you may lose title of the parent page, if that is the case reset it here:
document.title="abc";
}
Posted by
SF
at
12:29 pm
0
comments
rw.Width = Unit.Pixel(800);
rw.Height = Unit.Pixel(600);
rw.Behaviors = WindowBehaviors.Move & WindowBehaviors.Maximize & WindowBehaviors.Close;
Posted by
SF
at
3:21 pm
0
comments
question:
1. add brackets around a value
2. display or hide a string depending on a value. e.g. show "IDExists" in a textbox if Fields!ID != null, otherwise hide it
solution:
1. ="MemberID: (" & Fields!ID.Value &")"
2. =IIF (IsNothing(Fields!Id.Value), "","IdExist")
Posted by
SF
at
3:17 pm
0
comments
http://www.telerik.com/help/aspnet/window/postbackandcloseonreload.html
Posted by
SF
at
4:01 pm
0
comments
Filter.Value = "LastName LIKE '" + tbLastNameFilter.Text.Trim().Replace("'", "''") + "%'";
Posted by
SF
at
3:53 pm
0
comments
http://support.microsoft.com/kb/139444
Posted by
SF
at
4:50 pm
0
comments
http://blog.crowe.co.nz/archive/2007/04/16/728.aspx
http://geekswithblogs.net/wpeck/archive/2009/04/30/quotthe-microsoft.jet.oledb.4.0-provider-is-not-registered-on-the-local-machine.quot.aspx
http://www.telerik.com/support/kb/aspnet-ajax/general/error-on-64-bit-windows-machines-the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine.aspx
Posted by
SF
at
10:08 am
0
comments
http://blog-mstechnology.blogspot.com/2009/06/turn-off-saving-auto-recovery.html
Posted by
SF
at
10:08 am
1 comments
found this one useful
http://www.dotnetspider.com/resources/28823-All-Sample-Connection-String-for-All-database.aspx
Posted by
SF
at
10:04 am
0
comments
set the Anchor to (Top, Bottom)
Posted by
SF
at
3:40 am
0
comments
need to use "datagridview1.EndEdit()" in "datagridview1_CellContentClick" event to finalize the editing of current row so that the changes made to the current row (in this case the change of check status) is submitted
Posted by
SF
at
1:01 am
0
comments
cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\ temp\\abc.mdb;User Id=admin;Password=;");
or
cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\ abc.mdb;User Id=admin;Password=;");
Posted by
SF
at
9:16 pm
0
comments
this is because the driver is not x64. Solution: in project properties --> Build, select x86 in Platform Target
Posted by
SF
at
3:17 am
0
comments
in windows form application you can use Application.OpenForms collection to find the forms opened
Posted by
SF
at
3:16 am
0
comments
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'vw_abc')
DROP VIEW [dbo].[vw_abc]
Posted by
SF
at
11:47 am
0
comments
Posted by
SF
at
11:30 am
0
comments
SELECT CONVERT(VARCHAR(10),GETDATE(),111)
Posted by
SF
at
3:58 pm
0
comments
the master table row must be expanded to open the detailtable before the value of the control can be accessed:
Posted by
SF
at
3:13 pm
0
comments
to fix it, right click on the aspx page in solution explorer and select Convert to Web Application"
Posted by
SF
at
3:36 pm
0
comments
e.Item.OwnerTableView.Rebind();
this only rebinds the detailtable, so the current expanding status will remain.
Posted by
SF
at
11:17 am
0
comments
when you have a FormTemplate for insert and update in RadGrid.MasterTable, there is no commangArgument, therefore the record's primary key can not be passed on using commandargument.
This can be done by
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "Update")
{
int RecordId= Convert.ToInt32(RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["RecordId"].ToString());
}
}
Posted by
SF
at
4:21 pm
0
comments
protected void ReBindExpandedDetailTable()
{
foreach (GridDataItem item in RadGrid1.Items)
{
string aaaValueString= item.GetDataKeyValue("aaa").ToString();
if (aaaValueString==
{
if (item.Expanded == true)
{
GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0];
nestedView.Rebind();
}
}
}
}
Posted by
SF
at
2:16 pm
0
comments
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
//to hide AddNewRecord button
cmditm.FindControl("InitInsertButton").Visible = false;//hide the text
cmditm.FindControl("AddNewRecordButton").Visible = false;//hide the image
//to hide Refresh button
cmditm.FindControl("RefreshButton").Visible = false;//hide the text
cmditm.FindControl("RebindGridButton").Visible = false;//hide the image
}
}
Posted by
SF
at
12:40 pm
6
comments
I was able to update any records in the grid. However when I clicked on Add New Record, I received an error "specified cast is not valid" on the boolean field "IsActive".
see code below for my ASPX page content
The solution is:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
GridEditCommandColumn editColumn = (GridEditCommandColumn)rgQualificationList.MasterTableView.GetColumn("EditCommandColumn");
editColumn.Visible = false;
e.Canceled = true;
//Prepare an IDictionary with the predefined values
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
//set initial checked state for the checkbox on init insert
newValues["IsActive"] = false;
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
Posted by
SF
at
12:03 pm
1 comments
found this code library useful
http://www.telerik.com/community/code-library/aspnet-ajax/grid/display-radgrid-row-details-in-ajaxtoolkit-modalpopupextender.aspx
Posted by
SF
at
12:50 pm
0
comments
protected void ShowOrHideNestedTableView()
{
foreach (GridDataItem CS in rgABC.Items)
{
if (CS.OwnerTableView.Name == "AAA")
{
if (cb123.Checked)
{
CS.Parent.Visible = true;
CS.Visible = true;
}
else
{
CS.Parent.Visible = false;
CS.Visible = false;
}
}
}
}
protected void rgScheduleList_PreRender(object sender, EventArgs e)
{
ShowOrHideNestedTableView();
}
Posted by
SF
at
3:35 pm
0
comments
val1 is an integer
val2 is a boolean
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("window.open(abc.aspx?val1=" + val1Value.ToString() + "');");
ScriptManager.RegisterClientScriptBlock(this.upd1, this.upd1.GetType(), "abc", sb.ToString(), true);
Posted by
SF
at
2:59 pm
2
comments
val1 is an integer
val2 is a boolean
in page 1:
aspx:
c#:
RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("xxx('" + val1+ "',true);");
in page 2
c#
if (!string.IsNullOrEmpty(Request["val2"]))
{
if (bool.Parse(Request["val2"]))
----logic here---------
}
if (!string.IsNullOrEmpty(Request["val1"]))
{
if (int.Parse(Request["val1"])>0)
----logic here---------
}
Posted by
SF
at
2:46 pm
0
comments
use COALESCE to manage a nullable db value, reference:
http://msdn.microsoft.com/en-us/library/ms190349.aspx
Posted by
SF
at
3:50 pm
0
comments
Error: Could not load file or assembly 'Telerik.Web.UI, Version=2009.1.402.X, Culture=neutral, PublicKeyToken=XXXX' or one of its dependencies
Found some useful sources here:
This is the one helped me to solve my problem
Another one here
one more
Another one here Here
Posted by
SF
at
5:45 pm
0
comments
GroupingSettings-CaseSensitive="false"
Posted by
SF
at
5:22 pm
0
comments
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ABC")) == "Text To Be Found")
e.Row.Visible = false;
}
}
Posted by
SF
at
3:11 pm
0
comments
RadGrid1.MasterTableView.Columns.FindByUniqueName("ABC").Visible = false;
Posted by
SF
at
3:13 pm
0
comments
my code that has problem sorting template columns:
the instruction says "the SortExpression value should match the data field you want to sort on (typically the field a control in the template is bound to)". I made sure this rule is applied but the problem remained. Then I removed the HeaderTemplate components, instead I added value to HeaderText property in the GridTemplateColumn level. This solved the problem, not sure why though.....
the new code looks like:
...........
.......
Posted by
SF
at
2:11 pm
0
comments
protected void ABC_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e){if (e.CommandName == "PerformInsert"){//make sure the insert user control closes automatically after insertede.Item.OwnerTableView.IsItemInserted = false;}}
Posted by
SF
at
2:06 pm
0
comments
* Delete the .designer.cs file
* convert the .aspx or ascx file into a webapplication by right clicking on it
Posted by
SF
at
5:45 pm
0
comments
Checked=' < % # DataBinder.Eval( Container, "DataItem.Active" ) % >'
Posted by
SF
at
4:22 pm
0
comments
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
//enter the code here
}
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormInsertItem && RadGrid1.MasterTableView.IsItemInserted)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
(insertItem["abc"].Controls[0] as TextBox).Text = "hello world";
}
}
Posted by
SF
at
9:23 am
0
comments
my web.config has multiple connection strings.
when I right click on a table adapter in a dataset in design view, select "configure...", the dataset configuration window pops up. Naturally you'd just make the changes that you want to the query and click on Finish. If this table adapter doesn't use the first connection string listed in the web.config, visual studio will automatically change the connection string to the first one listed in the web.config.
In order to fix the problem when you first open up the configuration window click on Previous to go back to the connection string selection view, RESELECT the connection string. If you happened to encounter this error until this stage right click on the empty area of the dataset design view and select View Code. Then delete the unused connection string.
Posted by
SF
at
11:23 am
1 comments
when i tried to enter ipconfig in cmd mode it says: not valid command.
the solution is: right click on the cmd program and select "run as administrator".
why couldn't Vista run my programs as administrator when i logged in as administrator? this is stupid!
Posted by
SF
at
8:51 am
0
comments
found this tool very useful
http://www.mobchoice.com.au/compare-cap-plans-spreadsheet
Posted by
SF
at
9:42 am
0
comments
see below my code. every "\n" works fine except the ones after "Event: {0}" and "Start Date: {1:D}", basically the Event, Start Date and End Date are printed on same line. can anyone help please? thanks in advance.
string.Format(
"Schedule Details: \n" +
"Event: {0}\n"+
"Start Date: {1:D} \n" +
"End Date: {2:D} \n" +
"Location: {3} \n"
,schedule.event,
schedule.startDate,
schedule.endDate,
schedule.location);
I tried ""Event: {0}"+ Environment.NewLine" and "Event: {0}\r" and "Event: {0}/r/n" got the same result
==============
Schedule Details:
Event: Basketball Match Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009
Location: Como
================
Then I tried "Event: {0}\n"+ Environment.NewLine" and "Event: {0}\r"+ Environment.NewLine" and "Event: {0}/n/r" got this result (an additional line)
==============
Schedule Details:
Event: Basketball Match
Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009
Location: Como
================
It seems that it works either for no newline or 2 new lines, but not for 1 newline. I tried to take out "Event" everything else worked just fine, so the problem must be with "Event"?
The Event has datatype of "string", startDate and endDate are datetime, location is string. A sample of Event value is "Attend Class Certificate III in Basketball".
Eventually the problem is solved, not sure why though.....:
I put single quotes around the Event value, not sure how exactly but it worked.
"Event: '{0}'\n"+
Posted by
SF
at
2:10 pm
0
comments
Labels: ASP.NET), new line, partially works (C#, string.format
foreach(datarow in the query result)
{
ListItem currentCheckBox = CheckBoxListABC.Items.FindByValue(datarow ["TheFieldName"].ToString());
if (currentCheckBox != null)
{
currentCheckBox.Selected = true;
}
}
Posted by
SF
at
9:14 am
0
comments
Labels: ASP.NET, checkboxlist, databinding, select
using System.Globalization;
..
..
..
..
..
string ManipulatedString= CultureInfo.CurrentCulture.TextInfo.ToTitleCase("OriginalString");
Posted by
SF
at
5:34 pm
0
comments
Labels: ASP.NET, C#, capitalize first letter, titlecase
in my case PageA has a buttonA that opens PageB. The code is "response.redirect("PageB.aspx");"
on PageB I have some methodM to call under condition "if (!IsPostBack)"
After I clicked on ButtoA to open PageB, methodM is trigerred.
but when I use the PREVIOUS button on Internet Explore to go back to PageA and click on NEXT button to go back to PageB the methodM didn't fire.
How can I catch the Previous and Next button click event?
the answer is adding the code below into Page_Load in the target page, this line of code will force the target page to load from server instead of cache
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Posted by
SF
at
1:00 am
0
comments
Labels: button, IE, ispostback, load from server, next, previous, stop cache
http://www.asp.net/learn/data-access/tutorial-01-cs.aspx
Posted by
SF
at
8:04 pm
0
comments
Labels: asp.net 2.0, data access, vs2005 express
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
return clientIPAddress;
Posted by
SF
at
7:10 pm
0
comments
Labels: 2.0, ASP.NET, C#, retrieve IP
without parameter: LIKE '%abc%'
with parameter: LIKE '%'+@searchString+'%'
Posted by
SF
at
3:53 pm
0
comments
Labels: keyword search, LIKE, MSSQL, operator, parameter