Thursday, August 06, 2009
Monday, August 03, 2009
C# ASP.NET use StringBuilder to export a txt file
Posted by
SF
at
11:30 am
0
comments
Thursday, July 30, 2009
sql get date within a datetime value
SELECT CONVERT(VARCHAR(10),GETDATE(),111)
Posted by
SF
at
3:58 pm
0
comments
Friday, July 24, 2009
RadGrid allocate checkbox control within detailtable
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
Monday, July 06, 2009
lost designer.aspx in asp.net web application
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
RadGrid: rebind detailtable after command execution
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
Friday, July 03, 2009
fetch the record primary key from MasterTable while using FormTemplate for insert and update
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
Thursday, July 02, 2009
RadGrid: rebind detailtable from external event
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
RadGrid: hide add new and refresh buttons from code behind
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
RadGrid: problem displaying bool value in formtemplate type edit form insert mode
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
Wednesday, July 01, 2009
Display RadGrid row details in AjaxToolkit ModalPopupExtender
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
Thursday, June 18, 2009
show or hide nested table views RadGrid SP1 Q1 2009
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
Wednesday, June 17, 2009
aspx c# open new window in button click event when the button is placed inside an ajax update panel
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
aspx passing on multiple parameter values in URL
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
Thursday, June 04, 2009
COALESCE
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
Monday, May 25, 2009
Error: Could not load file or assembly 'Telerik.Web.UI, Version=2009.1.402
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
Friday, May 22, 2009
making radgrid filters case insensitive
GroupingSettings-CaseSensitive="false"
Posted by
SF
at
5:22 pm
0
comments
Friday, May 01, 2009
locate and hide BoundField in gridview asp.net c#
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
Friday, April 17, 2009
RadGrid hide column in export
RadGrid1.MasterTableView.Columns.FindByUniqueName("ABC").Visible = false;
Posted by
SF
at
3:13 pm
0
comments
sorting problem - RadGrid GridTemplateColumn
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