|
Hi ...
I am using one asp.net 2 Gridview control. I am binding it with a datatable. Now I want to hide two columns in the Gridview. How to do that ..Plz help me
This is my code...
DataTable dt = new DataTable("STEPS");
DataColumn dcOrder = new DataColumn("Order", typeof(Int32));
DataColumn dcName = new DataColumn("Name", typeof(string));
//Datacolumns are added to table dtsteps.
dt.Columns.AddRange(new DataColumn[] {dcOrder, dcName);
.....
//Assigning dtsteps as the datasource of my gridview dgsteps
MyGridView.DataSource = dt;
MyGridView.DataBind();
Thanks in advance....
Ranjith
|
|
|
|
|
just do the following:
datagrdview.Columns[0].Width = 0;
this will hide the 0th column of the datagridview.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
There is no property "Width" for datagridview.columns. There i found a visible property but it doesnt work
Ranjith
|
|
|
|
|
this is what u have to do after setting the data to the datagrid.
dataGridView1.Columns[0].Width = 0;
This should be enough
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
But I couldnt find any property Width for "dataGridView1.Columns[0]"
Ranjith
|
|
|
|
|
This is the better method.
dt.Columns["{COLUMN_NAME}"].ColumnMapping = MappingType.Hidden;
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
I tried this way also.. But it is not working
Ranjith
|
|
|
|
|
There are some set of server controls its property enabled= may be true or false,now in code behind how to find its current state and i am getting the controls id during runtime like this
foreach(Control c in form1.Controls)
{
............
}
and also there is no property like (c.Enabled) to check
Thanks In Advance
|
|
|
|
|
vamsimohan21 wrote: foreach(Control c in form1.Controls)
{
............
}
A web form has a Controls collection, the trick is that it's a tree, so you need to recurse over it.
Christian Graus - C++ MVP
|
|
|
|
|
Thank sir for that and i tried with that but not got any solution can u just pls tell me any sample code and also how to know whether the control is enabled or in disabled state during runtime
Thanks In Advance
|
|
|
|
|
Web controls do in fact have an Enabled property. I just checked. Maybe you need to post your code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
protected void Button1_Click1(object sender, EventArgs e)
{
foreach(Control c in mainform.Controls)
{
if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1)
{
(//HERE I HAVE TO CHECK WHETHER THE CURRENT CONTROL IS IN ENABLED/DISABLED STATE)
if (c.Enabled)
//Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled' C:\Documents and Settings\vamsi\My Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx.cs 86 23 C:\...\WebSite1\
{
.................
}
}
}
The above is the error i am reciving sir
THANKS IN ADVANCE
|
|
|
|
|
vamsimohan21 wrote:
if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1)
What on earth is this ? It's a mess.
if (c is LiteralControl)
{
// etc
}
vamsimohan21 wrote: //Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled'
Perhaps you need to have a derived class to have that property ?
LiteralControl lc = c as LiteralControl;
if (lc != null & lc.Enabled)
{
// Whatever
}
This still won't work, unless you just didn't bother to post the code that causes it to be recursive, but I don't see how it can be.
Christian Graus - C++ MVP
|
|
|
|
|
Hi
I began writing a c# program and everything was going ok until i tried to use asynchronous webrequests instead of synchronous ones (since the UI would be unresponsive while it was fetching the response) and i have a slight problem:
the user signs in by clicking a button on the form - the program fetches the data from the server asynchronously - the problem is with the callback function - when debugging i see that the request was successfully completed but when i try to access any controls (like filling a textbox with the response) from the callback function it just stop executing the function - no exceptions, no errors - i can still interact with the program but it just wont alter anything to do with the form's controls (the form's data members however were being altered with no issues - a string and an integer to be exact)
I'm a newbie at c# and i just started using the asynchronous method so if im doing sumthing wrong please advise
thank you for your time
|
|
|
|
|
A good first step would be to post some code, so we can offer some advice on it.
Christian Graus - C++ MVP
|
|
|
|
|
Hi
thanks for your quick reply
these are methods of my MainForm class (base class is Form)
<br />
private void getResult(String url, AsyncCallback callback)<br />
{<br />
try<br />
{<br />
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);<br />
request.Method = "GET";<br />
if(useCompression)<br />
request.Headers.Add("Accept-Encoding: gzip,deflate");<br />
request.CookieContainer = mainCookie;<br />
request.AllowAutoRedirect = true;<br />
request.AllowWriteStreamBuffering = true;<br />
<br />
IAsyncResult result = request.BeginGetResponse(callback, request);<br />
}<br />
catch (WebException wex)<br />
{<br />
MessageBox.Show("Error Connecting: Check your connection settings...\nDetails: " + wex.Status.ToString());<br />
return;<br />
}<br />
}
<br />
private void SignInButton_Click(object sender, EventArgs e)<br />
{<br />
DisableSignInControls();<br />
String url = mirror + "signin.aspx?user=" + UserNameComboBox.Text + "&pass=" + PasswordTextBox.Text;<br />
mainCookie = new CookieContainer();<br />
getResult(url, new AsyncCallback(signIn));<br />
}<br />
<br />
<br />
private void signIn(IAsyncResult result)<br />
{<br />
HttpWebRequest request = (HttpWebRequest)result.AsyncState;<br />
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);<br />
String responseResult = (useCompression ? decompressResponse(response) : new StreamReader(response.GetResponseStream()).ReadToEnd());<br />
int i = responseResult.IndexOf("<response>");<br />
if (i < 0)<br />
MessageBox.Show("Corrupt response. Please try again.");<br />
else<br />
{<br />
int j = responseResult.IndexOf("</response>");<br />
String temp = responseResult.Substring(i + 10, j - i - 10);<br />
if (temp != "")<br />
{<br />
String[] returnValues = temp.Split('|');<br />
if (returnValues.Length == 1)<br />
MessageBox.Show(returnValues[0]);<br />
else<br />
{<br />
sid = returnValues[0];<br />
num_messages = int.Parse(returnValues[1]);<br />
MessageNumber.Text = "Messages: Left " + num_messages;<br />
SignInGroupBox.Visible = false;<br />
SendSMSGroupBox.Visible = true;<br />
SignOutMenu.Visible = true;<br />
FillContacts();<br />
}<br />
}<br />
}<br />
EnableSignInControls();<br />
FillUsers();<br />
}<br />
the other functions are also part of the mainform class and they all make changes to the controls on the form.
do you need more info?
thanks again.
|
|
|
|
|
wajih.boukaram wrote: IAsyncResult result = request.BeginGetResponse(callback, request);
Doesn't result just get discarded ? And where is the callback hooked up to a method ?
Christian Graus - C++ MVP
|
|
|
|
|
yea it does but all that matters is the callback function (which i assigned when i called getResult(url, new AsyncCallback(signIn));
so its hooked up to signIn
it works fine the way it is - only problem is changing the form's control values - i think it might have something to do with threading because if i try calling the function a second time (I hate c# sometimes) it says sumthin about accessing an object that was not created on the same thread - when i first tried to do this asynchronously i actually just created a new thread that called my initial signIn function which was just a regular function and not a callback - i got the same error message when acessing the controls.
any suggestions?
thanks for your replies.
|
|
|
|
|
I was just wondering if anyone has managed to create a C# object that is exposed as a COM object and successfully insert it into the Running Obhect Table (ROT). Just as important, once in the table have you been able to extract it and actually call a method on it.
To test this, I have created two projects. The first one creates the C# object and inserts in into the ROT. It then waits until cancelled. The second one attempts to retrieve the object from the ROT. The second project contains a reference to the dll that contains the C# object created in the first project.
I believe I can successfully insert the object into the Running Object Table. As I can see the object in the ROT if I dump the contents.
When I try to access the entry, I seem to be able to pull it out of the table. But when I try to bind to the object
<br />
iMoniker.BindToObject(ctx, iMoniker, ref IID_ICancelAutoplay, out o);<br />
I get a "System.IO.FileNotFoundException" indicating "The specified module could not be found (Exception from HRESULT:0x8007007e)".
Any thoughts, hints would be greatly apreciated. I'd even be willing to be spoon feed on this one.
Thanks
Tim
|
|
|
|
|
Hi all,
I'm currently making an application for graphical manipulation of data. (i.e. a graph) Due to the interaction requirements I've used opengl to do the rendering due to its great speed. The problem I'm having is concerning the rendering strings/fonts.
I'm currently using the Tao libraries and the glutBitmapString function to render my text which has sufficed until now. On the Y axis of the graph I need to be able to render the text of the axis label vertically, as is common. Yet I cannot find anything to do this.
I've looked at the NeHe tutorials about rendering fonts, but they seem to be all in C++ and I cant find anything that will work in C#.
Does anyone have any ideas of how I go about doing this? I'd really appriciate any help at this point as currently I'm at a total loss.
|
|
|
|
|
Does glRotatef( -90, 0, 0, 1) (or whatever the Tao equivalent is) before calling glutBitmapString work?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
No, unfortunately not. I don't think that glutBitmapString has the ability to render text at any angle. I've looked for an alternative font library, but I either can't find a suitable one, or they are not created for use in C#
Edit: I've also tried using the glutStrokeString function, but I cant get this to render anything at all.
-- modified at 6:55 Thursday 16th November, 2006
|
|
|
|
|
hi
i want to get position of my datarow in dataset, How to do that ??
i am using vC# 2005
thanks
|
|
|
|
|
Well, a DataSet doesn't contain rows directly. Rather, it contains DataTables, which then contain rows. To find a row in a table in a dataset, you need to iterate over all the DataTable objectss, then look for the row in each table. Something like this:
int GetIndexOfRow(DataSet dataSet, DataRow row)
{
foreach(DataTable table in dataSet.Tables)
{
int index = table.Rows.IndexOf(row);
if(index != -1)
{
return index;
}
}
return -1;
}
|
|
|
|
|
I am displaying blocks of text in a datagridview control. The column is setup to not wrap or size. The first x characters are shown and then truncated. Since the column type is string, the datagridview shows the entire cell contents in a tooltip. Is there a way to control the font of this default behavior? I just need to increase the font size from what looks to be 10pt to 12pt or 14pt.
Any information would be greatly appreciated.
Steve
|
|
|
|