|
If what you want to do is to delete a column from the underlying database table I'm not sure I can help you on that.
If what you want h/ever is to simply hide the column from the GridView this should work otherwise you can replace GridView1.Columns.Remove(GridView1.Columns[i]); with GridView1.Column[i].Visible = false;
I've tested the previous code and it worked.
Why not post more code for us to see where you're getting it wrong?
|
|
|
|
|
by using above syntax also..i can't see anychange in the table..i can see all the columns..the 0(zero) value cell columns are not hiding..
actullt my task is to delete those columns..am unable to do that..
atleast i want to try with hiding those columns..
below i copied my code of populating data into gridview and the rowdelete event..
protected void Page_Load(object sender, EventArgs e)
{
PopulateGrid();
}
public void PopulateGrid()
{
SqlConnection sqlConn = null;
SqlDataAdapter da = null;
try
{
string connString = null;
SqlCommand cmd1;
connString = System.Web.Configuration.WebConfigurationManager.AppSettings["SqlServerConnectionString"];
sqlConn = new SqlConnection(connString);
sqlConn.Open();
cmd1 = new SqlCommand("[MED].[usp_SelectAllSDNCounts]", sqlConn);
cmd1.CommandType = CommandType.StoredProcedure;
da = new SqlDataAdapter(cmd1);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
finally
{
sqlConn.Close();
da.Dispose();
da = null;
}
}
public void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
foreach (GridViewRow Row in GridView1.Rows)
{
for(int i=0; i<11; i++)
{
if (Row.Cells[i].Text == "0")
{
GridView1.Columns[i].Visible=false;
}
}
}
}
|
|
|
|
|
Change:
protected void Page_Load(object sender, EventArgs e)
{ PopulateGrid();
}
to:
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
PopulateGrid();
}
}
Does this help? 
|
|
|
|
|
no..hmmm it remains the same..i can see the table with all column ..
if u want to know my design page ..see below..
%@ Page Language="C#" AutoEventWireup="true" CodeFile="MedPending.aspx.cs" Inherits="Maintenance_MedPending" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" >
<div>
</div>
<asp:Panel ID="Panel1" runat="server" style="position:absolute; left: 184px; top: 82px;" Width="740px" CssClass="borderPanel" Height="177px">
<table style="width:600px;" class="borderPanel">
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" HeaderStyle-HorizontalAlign="Center" Width="592px" style="position:absolute; left: 68px; top: 26px;" CssClass="GridRowGrayBorder" >
<RowStyle CssClass="GridRow" />
<HeaderStyle CssClass="HeaderRow" HorizontalAlign="Center" />
<EditRowStyle CssClass="GridRow" />
</asp:GridView>
</td>
</tr>
</table>
</asp:Panel>
</form>
</body>
</html>

|
|
|
|
|
1. Try putting a breakpoint in the code provided and see if the Row's Cell Text ever evaluates to "0". Does it ever enter the function i gave you?
2. Have you hooked the Row_Deleting method to the control calling it? If not add:
OnRowDeleting = "GridView1_RowDeleting" to this:
<gridview id="GridView1" runat="server" headerstyle-horizontalalign="Center" width="592px" style="position:absolute; left: 68px; top: 26px;" <b="">OnRowDeleting = "GridView1_RowDeleting" CssClass="GridRowGrayBorder">
Or alternatively in Page_Load add:
GridView1.RowDeleting+=new GridViewDeleteEventHandler(GridView1_RowDeleting);
Hope this helps
|
|
|
|
|
If this suggestion helped you, kindly say so, so the thread will be marked as resolved.
|
|
|
|
|
Hello there!
I have very strange problem and I hope someone will help me because I'm running out of time. So, the deal is - I'm working on a project for my graduation, which is a web site, connected to a SQL Database. It was working perfectly, until I decided to make users and roles. I run the aspnet_regsql.exe, which created in my database some tables to manage the users, but when I try to configure the roles through Web Site Administration Tool it cannot find my database...It's strange because when I execute my queries it works fine.
Can anyone tell me why the Web Site Administration Tool doesn't see my database?
Thanks in advance!!!
|
|
|
|
|
I guess your Web Site Administration Tool hasn't got the rights to show you the database.
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi There,
I am retrieving Hidden Field value through javascript but it is showing me one error that is
document.getElementById("ctl00_ContentPlaceHolder1_hfUpd") has no properties
I tried all following ways also:-
document.getElementById("hid").value
document.getElementById('hid').value
document.getElementById("ctl00_ContentPlaceHolder1_hfUpd").value //Using ControlID
Previously I tried used following code and it working fine.
document.getElementById("hid").value
But This Code Is Not Working.Is There any problem of Content Place Holder.
My Code To retrieve value:-
var hidflag=document.getElementById('<%=hfUpd.ClientID%>').value
|
|
|
|
|
try $get('<%=hdf.ClientID%'>.value
|
|
|
|
|
$get is an AJAX function that is simply shorthand for document.getElementById
only two letters away from being an asset
|
|
|
|
|
Good day,
I've decided to implement articles reading/writing in my webapp. So i sat down and started thinking about how should i accomplish my goal. I came up with the following idea:
1. Article List / Search form
2. Article Add / Edit form
3. Article Detail form.
However i'm not quite sure "what is the whole picture behind the scenes". I was thinking of the following:
When composing / editing an article there should be a input text control ( Multiline textbox for example ) which acceps HTML. My question here is: Is it acceptable to develope that kind of a control, since only the editors and administrators will be able to access this page. Is that the right way to achieve this ( html gives a really big power when wrtiting article ... but it could be harmful in the wrong hands ) ?
The markup will be stored in MS SQL database.
When displaying the markup in the article, should i use a "Label" control to achieve this. Since this control is rendered like a it can be really useful to display HTML. Is this the right way ?
Thanks in advance.
Regards, Hris
|
|
|
|
|
Hello Friends,
I've a folder named "noida" in my project and some pages in that folder And now i've to open those pages like http://noida.saamstesting.com/Page1.aspx .
|
|
|
|
|
|
I have login page with both button click and text changed event having same code.
If i disable the code on buttonclick event and enable the textcox changed event,if i click on the button, page is redirecting to the next page which is wrong.Why it is happening?
Which event calls first button click event or textchanged event.
so i am testing both cases.
Otherwise wats the solution to do both the ways?
I wanted to login either through button click or by click 'enter'.
If u r free please give me the reason and solution
kissy
|
|
|
|
|
You should set the login button as the default button on your page. The you don't have to handle the textchange event from your textbox, the enter key will cause the button click event.
only two letters away from being an asset
|
|
|
|
|
|
Do you even look at other responses before posting yours? Your response was redundant, stop clouding up the forum with such nonsense.
only two letters away from being an asset
|
|
|
|
|
|
The only thing worse than the morons asking around here, is the morons answering redundantly, or with ignorance. Mark is a respected member of this community and he is upholding the standards we used to have around here.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
|
|
|
|
|
Hi Mark Nischalke,
What if the member asked you how to set the login button as the default button.
Will you nag him that he does not have basic knowledge in .NET.
Don't think that People posting questions are brilliant like you. Note that there may be some beginners, student among them.
Posting message like this shows your level of maturity.
|
|
|
|
|
Nice of you to create another account just to reply here. I don't hide behind false accounts and aliases.
only two letters away from being an asset
|
|
|
|
|
Nice hit. You got my 5.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
I am beginner to the .NET world.
Since some people abusing beginners in CodeProject forums, i am not posting questions here.
But i started reading articles in this site.
Everybody in this forum should consider the beginners also. Your skill should be helpful not only experts but also some beginners and students.
I am not asking you to teach .NET. But you should not abuse them when you answer them.
|
|
|
|
|
Is answering a question in the CodeProject a mistake?
Could you please find any inappropriate, false answer from all my posts?
As I don't have time to debate with you, I have removed my previous messages from this thread.
|
|
|
|