Google Brother Up
2008/04/03
Authentication in ASP.NET
http://www.c-sharpcorner.com/UploadFile/lmoningi/AuthenticationAndAuthorizatio11252005233533PM/AuthenticationAndAuthorizatio.aspx
http://msdn2.microsoft.com/en-us/library/ms978378.aspx
2008/04/02
CustomValidator
2008/03/04
Convert from String to Float in C#
1) String to Double to Float (indirectly)
fc.Price = (float)Convert.ToDouble(txtPrice.Text);
2) String to Float (directly)
fc.Price = float.Parse(txtPrice.Text);
2008/02/21
The GridView 'gvManageProducts' fired event RowDeleting which wasn't handled.
protected void gvManageProducts_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//required -do not remove
}
and also write this:-
protected void gvManageProducts_SelectedIndexChanged(object sender, EventArgs e)
{
//required -do not remove
}
2008/02/20
Pass a String (List) to a Stored Procedure and Update
@List nvarchar(4000) -- value assigned to @List from DataLayer
AS
BEGIN
declare @ProdId2 int;
declare @Status2 nvarchar(100);
declare @CountRows int;
mailto:declare@val int;
declare @i int;
set @i = 1;
-- format of @List is @List = {1,True;2,False;3,True;4,False;5,False;}
-- execute sprocUpdateStatusInProductMaster ';1,True;2,False;3,True;4,False;5,False;'
set @List = ltrim(rtrim(Substring(@List,CharIndex(';',@List)+1,Len(@List)))); -- to eliminate the first semicolon ;
while(len(@List)>0)
BEGIN
set @ProdId2 = ltrim(rtrim(Substring(@List,1,CharIndex(',',@List)-1)));
set @List = ltrim(rtrim(Substring(@List,len(@ProdId2)+2,len(@List))));
set @Status2 = ltrim(rtrim(Substring(@List,1,CharIndex(';',@List)-1)));
set @List = ltrim(rtrim(Substring(@List,len(@Status2)+2,len(@List))));
update tblProductMaster set IsActive = @Status2
where ProductID = @ProdId2;
END
END
Label to Integer
int lblint = Int32.Parse(lbl.Text);
2008/01/11
To send two values from one page to another
Checkbox in to a boolean variable
if (chkCategoryActive.Checked)
{
fc.IsActive = true;
}
else
{
fc.IsActive = false;
}
or it can also be written as
fc.IsActive2 = Convert.ToBoolean(chkActive.Checked);
2008/01/10
Another Typical GridView
(%--(asp:GridView ID="dgdManageCategory" runat="server" AutoGenerateColumns="false" OnRowCommand="dgdManageCategory_RowCommand" OnRowDeleting="dgdManageCategory_RowDeleting" OnRowEditing="dgdManageCategory_RowEditing")
(Columns)
(asp:TemplateField HeaderText="CategoryID" Visible="false")
(ItemTemplate)
(asp:Label ID="lblCatID" runat="server" Text='(%# Eval("CategoryID")%)' /)
(/ItemTemplate)
(/asp:TemplateField)
(asp:TemplateField HeaderText="Status")
(ItemTemplate)
(asp:CheckBox ID="cbIsActive" runat="server" Checked='(%# Convert.ToBoolean(Eval("IsActive"))%)' /)
(/ItemTemplate)
(/asp:TemplateField)
(asp:BoundField DataField="CategoryName" HeaderText="Category Name" ConvertEmptyStringToNull="true" /)
(asp:TemplateField HeaderText="Edit")
(ItemTemplate)
(asp:Button ID="lbnEdit" runat="server" CommandArgument='(%# Eval("CategoryID")%)' CommandName="Edit" Text="Edit" /)
(/ItemTemplate)
(/asp:TemplateField)
(asp:TemplateField HeaderText="Delete")
(ItemTemplate)
(asp:Button ID="lbnDelete" runat="server" CommandArgument='(%# Eval("CategoryID")%)' CommandName="Delete" Text="Delete"
OnClientClick="JavaScript:return confirm('Are you sure you want to delete ');"/)
(/ItemTemplate)
(/asp:TemplateField)
(asp:TemplateField HeaderText="Products")
(ItemTemplate)
(asp:Button ID="lbnProducts" runat="server" CommandArgument='(%# Eval("CategoryID")%)' CommandName="Products" Text="Products" /)
(/ItemTemplate)
(/asp:TemplateField)
(/Columns)
(/asp:GridView)--%)
A Typical GridView
(asp:GridView ID="dgdManageUsers" runat="server" AutoGenerateColumns="False"
AllowPaging="true" PagerStyle-HorizontalAlign="Right" PagerSettings-Mode="Numeric" PagerSettings-PageButtonCount="3"
OnPageIndexChanging="dgdManageUsers_PageIndexChanging" EmptyDataText="No records found" OnRowDeleting="dgdManageUsers_RowDeleting"
OnRowCommand="dgdManageUsers_RowCommand" )
(Columns)
(asp:TemplateField HeaderText="CategoryID" Visible="False")
(ItemTemplate)
(asp:Label ID="lblUserID" runat="server" Text='(%# Eval("UserId")%)' /)
(/ItemTemplate)
(/asp:TemplateField)
(asp:BoundField HeaderText="Full Name" DataField="FullName" /)
(asp:BoundField HeaderText="Email" DataField="Email" /)
(asp:BoundField HeaderText="Registration Date" DataField="RegistrationDate" /)
(asp:TemplateField HeaderText="Edit")
(ItemTemplate)
(asp:Button runat="server" ID="btnEdit" CommandName="Edit" CommandArgument='(%# Eval("UserId")%)' Text="Edit"/)
(/ItemTemplate)
(/asp:TemplateField)
(asp:TemplateField HeaderText="Delete")
(ItemTemplate)
(asp:Button runat="server" ID="btnDelete" CommandName="Delete" CommandArgument='(%# Eval("UserId")%)' Text="Delete"
OnClientClick="JavaScript:return confirm('Are you sure you want to delete ');" /)
(/ItemTemplate)
(/asp:TemplateField)
(asp:TemplateField)
(ItemTemplate)
(asp:TextBox runat="server" ID="txtEditBox" Visible="False" Text='(%# DataBinder.Eval(Container.DataItem,"Email") %)' /)
(/ItemTemplate)
(/asp:TemplateField)
(/Columns)
(PagerSettings PageButtonCount="3" /)
(PagerStyle HorizontalAlign="Right" /)
(/asp:GridView)
2008/01/08
if ( ! Page.IsPostBack)
{
populateUserDetailsGrid();
}
-> Working with any kind of WebForm is posting data back to the server to enable data and command processing. The populateUserDetailsGrid() method is fired when this above condition is not true.
2008/01/07
The GridView 'gdABCD' fired event PageIndexChanging which wasn't handled.
DataGridPageChangedEventArgs to GridViewPageEventArgs.
2) If you set AllowPaging="true" or AllowSorting="true" on a GridView control without using a DataSourceControl DataSource (i.e. SqlDataSource, ObjectDataSource), you will run into the following errors: -
When changing the page on the GridView control: -
The GridView 'GridViewID' fired event PageIndexChanging which wasn't handled.
When clicking a column name to sort the column on the GridView control: -
The GridView 'GridViewID' fired event Sorting which wasn't handled.
As a result of not setting the DataSourceID property of the GridView to a DataSourceControl DataSource, you have to add event handlers for sorting and paging.
GridView PageIndex Code Behind
{
gridView.PageIndex = e.NewPageIndex;
gridView.DataBind();
}
Paging concepts in GridView
The DataGrid control requires additional coding for paging. The GridView control automatically supports paging by setting the PagerSettings property. The PagerSettings property supports four modes: Numeric ( default ), NextPrevious, NumericFirstLast, and NextPreviousFirstLast.
The Numeric mode displays numbered page links instead of "next/prev" links, and the NumericFirstLast option adds first and last page links. The GridView control's PagerStyle property can be used to set styles and the position of the pager.
Additionally, you can customize the pager buttons for the GridView control using a PagerTemplate.
Custom paging support in the GridView is supplied by the bound data source control as opposed to the AllowCustomPaging mechanism supplied by the DataGrid control.
2008/01/04
Get Row Index with Gridview Select Button
Inside that event, try something like this (with a label called 'Label1':
Dim row As GridViewRow = MyGridView.SelectedRow
Dim intRow as Integer=Row.RowIndex
label1.text=intRow.ToString
or
GridViewRow gvr = new GridViewRow();
gvr = dgdManageUsers.SelectedIndex;
int introw = gvr.RowIndex;
label1.text=intRow.ToString;
Some CSS Examples
background: #FFFFFF;
color: #000000;
margin: 0;
padding: 0;
}
p {
font-family: Arial;
font-size: 12px;
}
h1 {
font-family: Arial;
font-size: 14px;
color: #000000;
}
a:link {
font-family: Arial;
font-size: 12px;
color: #000000;
}
a:hover {
font-family: Arial;
font-size: 12px;
color: #FF0000;
}
.textbox {
font-family: Arial;
font-size: 12px;
border: 1px solid black;
}
.button {
font-family: Arial;
border: 1px solid black;
background-color: #CCCCCC;
}
.dropdownmenu {
font-family: Arial;
font-size: 12px;
background-color: #CCCCCC;
}
ItemStyle/HeaderStyle Properties not working with DataGrid
If you have a TD tag section in your page's stylesheet - -whatever properties you set there will normally override whatever you add into your DataGrid's Item styles.
2007/12/05
How To Print a Data Grid in C# and .NET
http://www.c-sharpcorner.com/UploadFile/mgold/HowToPrintaDataGridinCsHARPand.NET11212005060838AM/HowToPrintaDataGridinCsHARPand.NET.aspx
2007/11/30
Paging does not occur (Why?)
AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid with ID 'dgdManageUsers' when AllowPaging is set to true and the selected data source does not implement ICollection.
Solution
1. Solving AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid
2. This error usually comes when you are binding a paging enabled grid using DataReader. DataReader is forward only. So paging can't work. To solve this bind the grid with Dataset.
This works :)