|
Drag and drop a GridView and name it as GridView1
Try the below code
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable("Employee");
//Name Age Gender Mobile Phone Email
dt.Columns.Add("Name");
dt.Columns.Add("Age");
dt.Columns.Add("Gender");
dt.Columns.Add("Mobile");
dt.Columns.Add("Phone");
dt.Columns.Add("Email");
dt.Rows.Add("Anoop", "25", "Male", "996633352", "02255566", "anoopukrish@gmail.com");
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridView gridView = (GridView)sender;
GridViewRow gridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell tableCell = new TableCell();
//add Personal Info
tableCell.Text = "Personal Info";
tableCell.Attributes.Add("style", "text-align: center");
tableCell.ColumnSpan = 3;
gridViewRow.Cells.Add(tableCell);
//Add Contact Info
tableCell = new TableCell();
tableCell.Attributes.Add("style", "text-align: center");
tableCell.Text = "Contact Info";
tableCell.ColumnSpan = 3;
gridViewRow.Cells.Add(tableCell);
GridView1.Controls[0].Controls.AddAt(0, gridViewRow);
}
}
... There by u get the desired output...
____________________
Anoop Unnikrishnan
|
|
|
|
|
Your code is for webpage gridView control, it doesn't work for winform GridView Control.
Thank you for the codes, are you still have some codes for winform GridView Control?
|
|
|
|
|
Hello,
I was wondering if any one can help with right align the text in a data grid view column and formatting a data grid view column for money (eg. $ 100.00) any help would be great.
thanks, J
|
|
|
|
|
example :
DGV.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
DefaultCellStyle also have a property Format.
hope this will help
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks!! That worked great!!
|
|
|
|
|
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Good Day Everyone,
In Visual Studio 2005, there is this "Error List" where errors about your code will be shown after you build your application.
What object is this Error list? Can that object be used in my own application?
Thanks!
|
|
|
|
|
its a listview, yes, you can use it in your app
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
No, what I'm referring to is the actual "form/tab" that can be auto-hidden?
Thanks for the reply.
|
|
|
|
|
oh, then you will need 3rd party tool, search at google, there are lots of
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hello!
I'm working on a little tax-program.
For some calculations in the program, I need to use the "caret" (^) sign as it's normally used in mathematics..
2^2=4 for example..
How can I do that?
/Jop
|
|
|
|
|
double result = Math.Pow(double, double);
Or in your case:
int result = (int)Math.Pow(2.0, 2.0);
result should come out as 4.
And why oh WHY does Math.Floor, and Math.Ceil return double's? They return integers, so why not return an int
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
That solved my problem. Thx a lot!
/Jop
|
|
|
|
|
SK Genius wrote: And why oh WHY does Math.Floor, and Math.Ceil return double's? They return integers, so why not return an int
Because the rounding operations are floating point operations performed by the FPU. The result is a floating point number, and the methods reflect this.
The methods could of course have included casting so that they returned integer results, but if you then needed the value as a double, that would result in two casts without any good reason at all.
Also, the result of Math.Floor(1000000000000.0) doesn't even fit in an integer.
Some things doesn't make sense until you realise that the alternative makes even less sense.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Wednesday, February 27, 2008 8:39 PM
|
|
|
|
|
Guffa wrote: Some things doesn't make sense until you realise that the alternative makes even less sense.
Class comments ... made me chuckle!!
|
|
|
|
|
Ok, I really just wanted to use the word edification. ^ is the bitwise XOR in most computer programming languages.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
My problem is as follows. The program works by creating new dataTable from a schema that the user has specified. once the person creates the table they fill it out, and hit the save command. The dataset is then saved to the sample object and serialized for later use. The problem occurs after the file is reloaded to edit. The previous data saved correctly and is displated on the datagrid. However if i change the data and then hit the save command again, it does not appear to save. Upon closing and reopening of the file, the dataSet looks as the origonal. Please help me. thanks,
public Sample sample;
public void sampleToEdit( Sample s, string path )
{
dataGrid1.DataSource = s.sampleData;
dataGrid1.DataMember = "sample";
sample = s;
}
private void saveCmd_Click(object sender, System.EventArgs e)
{
if ( isNewSample )
{
// this code runs when sample is created
Container sampleContainer = getContainer( templateDir + "sampleContainer.dat" );
string filename = sampleDir + uniqueCode + ".smp";
sampleContainer.container.Add(filename);
setContainer(sampleContainer, templateDir + "sampleContainer.dat" );
sample.sampleData = dataGrid1.DataSource as DataSet;
storeSample( sample, filename );
}
else
{
// this code runs when someone opens table to edit
string filename = sampleDir + uniqueCode + ".smp";
sample.sampleData = dataGrid1.DataSource as DataSet;
sample.sampleData.AcceptChanges();
storeSample( sample, filename );
}
}
modified on Wednesday, February 27, 2008 7:26 PM
|
|
|
|
|
Hi All,
I'm just looking into a stack of messages generated by this tool and I'm just wanting to ask a couple of questions.
One of the warnings is about implementing IFormatProvider on this line of code:
MainScreenTitle.Content = Constants.App_Name + Constants.SampleSort_Version.ToString();
Constants.SampleSort_Version is a double. FXCop is saying SpecifyIFormatProvider. How do you go about implementing CultureInfo stuff? Is this an App.config thing?
Also i'm seeing AssembliesShouldHaveValidStrongNames error with a resolution of : "Sign 'SampleSort.Presentation.exe' with a strong name key." How do you sign .exe and assemblies properly to avoid things like this?
There are a load of other errors that I'm going to have to make my way through but i'm really new to C# and am still very much at the scratching head stage in the learning curve (what a curve though!).
Thanks,
James.
|
|
|
|
|
The warnings in FxCop will contain links that explains all of this in great detail.
In your specific cases, you should consider:
1. Constants.SampleSort_Version.ToString(CultureInfo.InvariantCulture);
2. Google for .NET strong name.
In some rare cases, you will need some other parameter instead of InvariantCulture.
Cheers,
Vikram.
If the radiance of a thousand suns
Were to burst at once into the sky
That would be like the splendor of the Mighty one—
I am become Death,
The shatterer of Worlds.
|
|
|
|
|
Thanks for the input Vikram. My little fingers will be a-Googlin plenty for the next few days!
|
|
|
|
|
Hello people. I've been having this issue for a couple of days, and maybe someone can help me.
I have a datagridview with a collection as datasource. This collection has some properties as boolean, so when I bind it to the datagridview, the columns type for that properties get the same type (boolean). For cosmetic issues, i want to change the true value for an "X" and the false value for a (blank), but when i try to change it in CellPainting Event of the Grid, it throws an exception saying that the types don't match and that the value "X" cannot be parsed as a boolean.
I have this little routine in CellPainting Event of the grid....
if (e.ColumnIndex >= 2)
{
if (this.dgCompare.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().ToUpper().Equals("TRUE"))
{
this.dgCompare.Rows[e.RowIndex].Cells[e.ColumnIndex].ValueType = typeof(string);
this.dgCompare.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "X";
}
else
{
this.dgCompare.Rows[e.RowIndex].Cells[e.ColumnIndex].ValueType = typeof(string);
this.dgCompare.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
}
}
As you can see, I'm changing the type of the cell before assining the new value.
Thanks in advance for your help!
|
|
|
|
|
ah, a long way
buddy if you have bind the DGV then you cannot change the type of any cell,
i think first you should remove the binding then do this code, and CellPainting Event is for painting graphics on control, you should use CellClick Event
simple and short code:
if (e.ColumnIndex >= 2)
{
dgCompare[e.ColumnIndex,e.RowIndex].ValueType = typeof(string);
if (dgCompare[e.ColumnIndex,e.RowIndex].Value.ToString().ToUpper().Equals("TRUE"))
dgCompare[e.ColumnIndex,e.RowIndex].Value = "X";
else
dgCompare[e.ColumnIndex,e.RowIndex].Value = "";
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thanks man, but is there any way to get around that without removing the binding?
|
|
|
|
|
hmm...i think its not possible
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I think i will have to construct a datatable in code and then set it as DGV's datasource.
Thanks!
|
|
|
|