Google Brother Up
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.