GridView Empty Cells

Discussion in 'ASP .Net Datagrid Control' started by Krish, Jan 11, 2006.

  1. Krish

    Krish Guest

    ******- I just posted this in asp.net newsgroup and realized i should have
    posted here ********
    Hello,

    I have GridView and after binding data i can see cells empty only (empty row
    is created), but i checked database there is data available. I just started
    using GridView, trying to learn after using DataGrid, pardon my ignorance.
    Here is the code.

    public void ImageButtonSubmit(object sender, ImageClickEventArgs e)
    {
    string SQL;
    DataSet ds = new DataSet();
    string pMajor = cboMajor.SelectedValue;
    SQL = "SELECT distinct M.cd_major,
    M.cd_cipfamily,M.cd_cipcode,ds_ciptitle as ds_cipdesc,
    M.in_translate,M.dt_trans_expire FROM km_major_cip M, km_etran_CIP F,
    km_reference R where R.cd_type='MAJOR' and R.cd_value='" + pMajor + "' and
    M.cd_major= R.cd_value and M.cd_cipcode=F.cd_cipcode and
    M.cd_cipfamily=F.cd_cipfamily
    MaintenanceCode mCode = new MaintenanceCode();
    ds = mCode.GetMajor(SQL);
    GridView1.DataSource = ds.Tables["Join10"];
    GridView1.DataBind();
    }


    public DataSet GetMajor(string selectSQL)
    {
    OdbcConnection cn = new OdbcConnection("DSN=myodbcConn;");
    cn.Open();
    DataSet ds = new DataSet();
    OdbcDataAdapter Ada = new OdbcDataAdapter();
    OdbcCommand sCmd = new OdbcCommand(selectSQL, cn);
    Ada.SelectCommand = sCmd;
    cn.Close();
    Ada.Fill(ds, "Join10");
    return ds;
    }

    <asp:GridView ID="GridView1" runat="server"
    AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
    CssClass="body" ToolTip="Major Code" Width="99%" BackColor="White"
    Font-Bold="False" ForeColor="Transparent" DataKeyNames="cd_major">
    <EmptyDataRowStyle BackColor="Silver" />
    <Columns>
    <asp:TemplateField HeaderText="Major Code
    &amp; Desc."></asp:TemplateField>
    <asp:BoundField HeaderText="CIP Family" />
    <asp:BoundField HeaderText="CIP Code" />
    <asp:BoundField HeaderText="CIP Description"
    />
    <asp:TemplateField HeaderText="Code
    Translate"></asp:TemplateField>
    <asp:TemplateField HeaderText="Dt.
    Expire"></asp:TemplateField>
    <asp:ButtonField HeaderText="Delete"
    ImageUrl="~/Images/delitemGrid.gif" ButtonType="Image" />
    <asp:ButtonField HeaderText="Edit"
    ImageUrl="~/Images/editgrid.gif" ButtonType="Image" />
    </Columns>
    <AlternatingRowStyle BackColor="Lavender"
    BorderColor="Blue" BorderStyle="None" />
    <RowStyle BackColor="Transparent"
    CssClass="body" ForeColor="Transparent" />
    <EditRowStyle BackColor="White" />
    <HeaderStyle BackColor="Transparent" />
    </asp:GridView>
    Any ideas ???
    Krish, Jan 11, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Krish

    GridView Empty Cells

    Krish, Jan 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,720
    Krish
    Jan 11, 2006
  2. Replies:
    0
    Views:
    522
  3. K B
    Replies:
    1
    Views:
    8,241
    brianguy16
    Feb 21, 2008
  4. Savvoulidis Iordanis

    Empty gridview cells and checking for empty string

    Savvoulidis Iordanis, Sep 5, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    518
    Savvoulidis Iordanis
    Sep 5, 2008
  5. Joel Finkel

    Cells[].Text or Cells[].Controls[0]

    Joel Finkel, Sep 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    306
    Joel Finkel
    Sep 1, 2003
Loading...

Share This Page