Feeds:
Posts
Comments

take a enum testEnum and a DropDownList ddlEnumData
public enum testEnum
{
one=1, two=2, three=3
}

foreach(testEnum te in Enum.GetValues(typeof(testEnum)))
{
  ddlEnumData.Items.Add(new ListItem(te.ToString(), Convert.ToInt32(te).ToString()));
}

This errors may appear when you are debugging , here are the how you will solve it

1. In the Internet Explorer, go to “Tools” -> “Internet Options”.

2. Switch to “Security” Tab.

3. Click on “Internet” (The Globe Icon. Its actually the default selected).

4. Click on “Custom Level” in the bottom.

5. Scroll down to find the “User Authentication” section.

6. Select “Automatic logon with current username and password”.

7. Click “Ok” twice to exit.

reference: http://geekswithblogs.net/ranganh/archive/2005/12/30/64446.aspx

css for asp:GridView

.Grid { border: solid 1px #FFFFFF; }
.Grid td
{
border: solid 1px #FFFFFF;
margin: 1px 1px 1px 1px;
padding: 1px 1px 1px 1px;
text-align: center;
}
.GridHeader
{
font-weight: bold;
background-color: #8b8dbb;
}
.GridItem
{
background-color: #e6e6e6;
}

.GridAltItem
{
background-color: white;
}

<asp:GridView ID=”grdPermitRequest” runat=”server” AutoGenerateColumns=”False” DataSourceID=”srcPermitRequest” Width=”100%” CssClass=”Grid”>
<HeaderStyle CssClass=”GridHeader”></HeaderStyle>
<AlternatingRowStyle CssClass=”GridAtlItem”/>
</asp:GridView>

CSS for ASP:HyperLink

.WhiteLink
{
color:#FFFFFF;
text-decoration: none;
font-weight:bold;
}
.WhiteLink:hover
{
background:#E6E6E6;
color:#000000;
text-decoration:none;
}

<asp:HyperLink ID=”lnkRequesList” runat=”server” NavigateUrl=”ViewRequestPage.aspx” CssClass=”WhiteLink”>Request Link</asp:HyperLink>

take a placeholder on your page and the write this code on your event. 

ctlSudentAddress ctlAddress=(ctlSudentAddress)LoadControl(“ctlSudentAddress.ascx”);

ctlAddress.showStudentAddress(ID);

PlaceHolder1.Controls.Add(ctlAddress);

Paging in DataGrid

aspx datagrid tag 

<asp:DataGrid id=”dgProducts” runat=”server” AllowPaging=”True” OnPageIndexChanged=”GridPageChange” PageSize=”4″ />

Code Base 

If Not Page.IsPostBack Then
DataFiller()
End If

Sub DataFiller()
Dim strConnection As String = “data source=(local);initial catalog=University; user id=sa; password=janina;”
Dim objConnection As New SqlConnection(strConnection)

Dim strSqlProducts As String = “SELECT * FROM Users where UserName like ’06-%'”
Dim objAdapter As New SqlDataAdapter(strSqlProducts, objConnection)

Dim objDataSet As New DataSet
objAdapter.Fill(objDataSet, “dtProducts”)

dgProducts.PagerStyle.NextPageText = “Next”
dgProducts.PagerStyle.PrevPageText = “Previous”
dgProducts.DataSource = objDataSet.Tables.Item(“dtProducts”)
dgProducts.DataBind()
End Sub

Sub GridPageChange(ByVal S As Object, ByVal E As DataGridPageChangedEventArgs)
dgProducts.CurrentPageIndex = E.NewPageIndex
DataFiller()
End Sub

white these code to page_load so Radio Button List will be generated
Dim strConnection As String = “data source=(local);initial catalog=testDB; user id=sa; password=1234;”

Dim strSQLforListBox As String = “SELECT distinct FirstName, ID ”
strSQLforListBox += “FROM Users”

Dim objConnection As New SqlConnection(strConnection)
Dim objCommand As New SqlCommand(strSQLforListBox, objConnection)

objConnection.Open()
radEmployees.DataSource = objCommand.ExecuteReader()
radEmployees.DataTextField = “FirstName”
radEmployees.DataValueField = “ID”
radEmployees.DataBind()
objConnection.Close()
 

Then we need to write the following codes in SelectedIndexChanged

Dim strConnection As String = “data source=(local);initial catalog=testDB; user id=sa; password=1234;”

Dim strSQLforGrid As String = “SELECT ”
strSQLforGrid += ” FirstName, LastName, ”
strSQLforGrid += “phone, PermanentAddress1 ”
strSQLforGrid += “FROM Users ”
strSQLforGrid += “WHERE ID= ” & radEmployees.SelectedItem.Value

Dim objConnection As New SqlConnection(strConnection)
Dim objCommand As New SqlCommand(strSQLforGrid, objConnection)

objConnection.Open()
DataGrid1.DataSource = objCommand.ExecuteReader()
DataGrid1.DataBind()
objConnection.Close()