TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
abdujalil chuliev
NA
400
41.6k
how to hide null cell before rotating GridView
Jun 15 2017 1:51 AM
I want my GridView to hide the column which has null row value then rotate. I have some code below. But it is checking value after rotating. There is only one selected row and many columns.
protected
void
btnSearch_Click(
object
sender, EventArgs e)
{
gvDb.DataSource = (c());
gvDb.DataBind();
hideNull();
}
public
DataSet c()
{
SqlConnection cn =
new
SqlConnection(cs);
cn.Open();
SqlDataAdapter ad =
new
SqlDataAdapter(
"select * from DESIGNSTABLE WHERE B210_APPL_NUMBER="
+ txtID.Text +
""
, cn);
DataSet ds =
new
DataSet();
ad.Fill(ds,
"DB"
);
gvDb.DataSource = ds;
gvDb.DataBind();
cn.Close();
return
ds;
}
public
DataSet FlipDataSet(DataSet my_DataSet)
{
DataSet ds =
new
DataSet();
foreach
(DataTable dt
in
my_DataSet.Tables)
{
DataTable table =
new
DataTable();
for
(
int
i = 0; i <= dt.Rows.Count; i++)
{
table.Columns.Add(Convert.ToString(i));
}
DataRow r =
null
;
for
(
int
k = 0; k < dt.Columns.Count; k++)
{
r = table.NewRow();
r[0] = dt.Columns[k].ToString();
for
(
int
j = 1; j <= dt.Rows.Count; j++)
r[j] = dt.Rows[j - 1][k];
table.Rows.Add(r);
}
ds.Tables.Add(table);
}
return
ds;
}
protected
void
hideNull()
{
Boolean hasData =
false
;
for
(
int
col = 0; col < gvDb.HeaderRow.Cells.Count; col++)
{
for
(
int
row = 0; row < gvDb.Rows.Count; row++)
{
if
(!String.IsNullOrEmpty(gvDb.Rows[row].Cells[col].Text)
&& !String.IsNullOrEmpty(HttpUtility.HtmlDecode(gvDb.Rows[row].Cells[col].Text).Trim()))
{
hasData =
true
;
break
;
}
}
if
(!hasData)
{
gvDb.HeaderRow.Cells[col].Visible =
false
;
for
(
int
hiddenrows = 0; hiddenrows < gvDb.Rows.Count; hiddenrows++)
{
gvDb.Rows[hiddenrows].Cells[col].Visible =
false
;
}
}
hasData =
false
;
}
}
Reply
Answers (
1
)
During bulk insert
get indian languages and foreign languages in dropdownlist