GridView Empty Cells

K

Krish

******- 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 ???
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top