View Single Post
  #5 (permalink)  
Old July 19th, 2007, 03:45 PM
vhrao vhrao is offline
Authorized User
 
Join Date: Oct 2004
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<asp:datagrid id="DataGrid1" runat="server" AllowCustomPaging="True" PageSize="1" AllowPaging="True"
                                            AutoGenerateColumns="False">
    <Columns>
        <asp:BoundColumn DataField="EMPID" HeaderText="EMP ID">
            <HeaderStyle Font-Underline="True" Font-Names="verdana"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="LNAME" HeaderText="Last Name">
            <HeaderStyle Font-Underline="True"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="PHONENO" HeaderText="Phone Number">
            <HeaderStyle Font-Underline="True"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="INSDATE" HeaderText="Req. Date">
            <HeaderStyle Font-Underline="True"></HeaderStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="APPROVEDDATE" HeaderText="App. Date">
            <HeaderStyle Font-Underline="True"></HeaderStyle>
        </asp:BoundColumn>
        <asp:TemplateColumn>
            <ItemTemplate>
                <asp:CheckBox id="Checkbox1" Text="Delete" runat="server"></asp:CheckBox>
            </ItemTemplate>
        </asp:TemplateColumn>
    </Columns>
    <PagerStyle Font-Size="8pt" Font-Bold="True" HorizontalAlign="Right" Position="TopAndBottom"></PagerStyle>
</asp:datagrid>
<PagerStyle BackColor="Navy" ForeColor="White" Font-Size="8pt"
Font-Bold="True" HorizontalAlign="Right"
NextPageText="Next >" PrevPageText="< Prev"
Position="TopAndBottom" />

Code behind:
void BindGrid()
{
    myConnection = new OracleConnection(ConfigurationSettings.AppSettings["oraClientConnStr"]);
    try
    {
        string classCode = DropDownListCourse.SelectedValue;
        string locCode = DropDownListLoc.SelectedValue;
        mySelectQuery = "SELECT * from Training.trschedules_view where classcode = " + classCode;
        myConnection.Open();
        myCommand = new OracleCommand(mySelectQuery, myConnection);
        myReader = myCommand.ExecuteReader();
        if (myReader.HasRows)
        {
            DataGrid1.DataSource=myReader;
            DataGrid1.DataBind();
        }
    }
    finally
    {
        myConnection.Close();
    }

}

private void Button1_Click(object sender, System.EventArgs e)
{
BindGrid();
}

Reply With Quote