By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

GridView Empty Cells

P: n/a
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 ???


Jan 11 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.