|
Hello Every Body,
I want to populate the grid view from the data base but i m not able to do so,
Actually i want to show selected feild only through coding,
Regards,
RAHUL
rahul saini
|
|
|
|
|
monuSaini wrote: I want to populate the grid view from the data base but i m not able to do so,
Why not? Is it a knowledge constraint or a coding constraint?
monuSaini wrote: Actually i want to show selected feild only through coding,
You will have to explain this better because at the moment i dont understand what you are asking\looking for.
|
|
|
|
|
Hi,
Thanks for replying me.
Actually i want bind selected columns only.
And i want to add edit button , delete button and an dropdownlist box in gridview
this is which i m not able do.
Regards,
Karan
rahul saini
|
|
|
|
|
monuSaini wrote: Actually i want bind selected columns only
I am assuming you are using VS2005 here.
If you have your grid bound to a datasource then use the grids "Edit Columns" property in design view to remove the columns from the datasource that you dont want to appear in your grid.
monuSaini wrote: And i want to add edit button , delete button and an dropdownlist box in gridview
You can add unbound columns which contain buttons etc again by using the Edit Columns option in design view.
If you need to access any of the controls you add then there are many articles on the web explaining how to do this. Take a look at the following article within the code project articles section.
http://www.codeproject.com/dotnet/AccessingControlsInsideGr.asp[^]
I hope this helps in some way.
|
|
|
|
|
Hi,
Yes i m working in VS2005
And also want to tell you that i m working on datagridview of windows application. In this i m not able to add button.
Regards,
Karan
rahul saini
|
|
|
|
|
Try looking at this page:
http://msdn2.microsoft.com/en-us/library/zkatshfa.aspx[^]
It explains how to add unbound columns to a gridview through code. There is also a link on the page which will take you to a step by step guide of how to add buttons through the designer.
If this is no help then here are the steps i followed:
1. Create a new windows forms application.
2. Add a data gridview to the form and bind it to a data source. (Customers table on the Northwind database)
3. Right click on the grid view and select Edit Columns.
4. Remove the columns you dont want to display from the data source.
5. Right click the grid view and select Edit Columns.
6. Click the Add button.
7. On the Add Column window select the "unbound column" option box.
8. Change the Type combo box to be DataGridViewButtonColumn
You now have a column which will contain a button.
Unless there is something i am mis-understanding then this should do what you were asking.
|
|
|
|
|
Hello Every Body,
I want to populate the grid view from the data base but i m not able to do so,
Actually i want to show selected feild only through coding,
Regards,
RAHUL
rahul saini
|
|
|
|
|
// Fill dataTableObject with your desired data
// and bind it to your grid view
datagridview1.datasource=dataTableObject;
and if you're doing in asp.net then,
gridview1.datasource=dataTableObject;
gridview1.databind();
|
|
|
|
|
|
Er nikesh yadav wrote: int results = com.ExecuteScalar;
Read the build output and it'll tell you how to correct it:
int results = com.ExecuteScalar();
|
|
|
|
|
Er nikesh yadav wrote: Re: Please correct the errror...
There is a lexical typo error in the string literal 'errror'.
Er nikesh yadav wrote: string sqlQuery = "select user,pwd from Login where user= ' " + this.TextBox1.Text + " ' and pwd=' " + this.TextBox2.Text + " ' ";
This statement has potential security hole error called 'SQL Injection Attack'
|
|
|
|
|
ExecuteScalar is a method so it needs () at the end
|
|
|
|
|
Don't delete your original question - It is considered rude.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Hi. Im making a database application for viewing/editing/searching. Im using the DevAge SourceGrid for database handling. I was told to ask on another forum becouse it was not a SourceGrid related problem. It works as it should in the its current state, but it need to evolve to be able to support more Tabs with grids then only one at a time. so I thought I should solve this dynamicly. I have writen a function that can be used to fill new Tabs, with a Panel and inside this Panel two datagrids. This function can be used to fill these dynamicly created datagrids and fill them with diffrent information from diffrent dataset's.
The problem is Im not sure how to determin what dynamicly created datagrid is currently viewed, and there for be able to be controlled and modefied by new values or what ever should happend with database releated functions as refresh,fitler,update info and so forth.
It is the "maDynamicDataGrid" I belive, I need to know the diffrence between these dynamicly created datagrids.
This is the response line I got before i got here.
"You must read the Tab structure and iterate on all the controls (Tab->Panel->Grid ...)"
Im posting code of the function for creating the dynamic Tab, with the grids.
public void AddNewDefaultDataGridTab( DataSet dynamicDataSet, string dynamicTable, string TabTitle, string columnFileToLoad)<br />
{<br />
dynamicTabNameArrayList.Add(TabTitle);
<br />
#region//-------------------------ADDS-ALL-COMPONENTS-FOR-NEW-TABLE-------------<br />
SourceGrid.DataGrid maDynamicDataGrid = new SourceGrid.DataGrid();<br />
<br />
maDynamicDataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)<br />
| System.Windows.Forms.AnchorStyles.Left)<br />
| System.Windows.Forms.AnchorStyles.Right)));<br />
maDynamicDataGrid.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;<br />
maDynamicDataGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;<br />
maDynamicDataGrid.DeleteQuestionMessage = "Are you sure to delete all the selected rows?";<br />
maDynamicDataGrid.DeleteRowsWithDeleteKey = false;<br />
maDynamicDataGrid.FixedRows = 1;<br />
maDynamicDataGrid.Location = new System.Drawing.Point(-1, 18);<br />
maDynamicDataGrid.SelectionMode = SourceGrid.GridSelectionMode.Row;<br />
maDynamicDataGrid.Size = new System.Drawing.Size(202, 83);<br />
maDynamicDataGrid.TabIndex = 9;<br />
maDynamicDataGrid.TabStop = true;<br />
maDynamicDataGrid.ToolTipText = "";<br />
<br />
SourceGrid.Grid maDynamicGroupGrid = new SourceGrid.Grid();<br />
<br />
maDynamicGroupGrid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)<br />
| System.Windows.Forms.AnchorStyles.Right)));<br />
maDynamicGroupGrid.FixedRows = 1;<br />
maDynamicGroupGrid.Location = new System.Drawing.Point(-1, -1);<br />
maDynamicGroupGrid.Name = "DynamicGroupGrid";<br />
maDynamicGroupGrid.OptimizeMode = SourceGrid.CellOptimizeMode.ForRows;<br />
maDynamicGroupGrid.SelectionMode = SourceGrid.GridSelectionMode.Row;<br />
maDynamicGroupGrid.Size = new System.Drawing.Size(200, 40);<br />
maDynamicGroupGrid.TabIndex = 10;<br />
maDynamicGroupGrid.TabStop = true;<br />
maDynamicGroupGrid.ToolTipText = "";<br />
<br />
System.Windows.Forms.Panel DynamicPanel = new Panel(); <br />
DynamicPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)<br />
| System.Windows.Forms.AnchorStyles.Left)<br />
| System.Windows.Forms.AnchorStyles.Right)));<br />
DynamicPanel.BackColor = System.Drawing.Color.Silver;<br />
DynamicPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;<br />
<br />
DynamicPanel.Controls.Add(maDynamicDataGrid);
DynamicPanel.Controls.Add(maDynamicGroupGrid);
<br />
DynamicPanel.Location = new System.Drawing.Point(-3, -3);<br />
DynamicPanel.Size = new System.Drawing.Size(206, 106);<br />
DynamicPanel.TabIndex = 26;<br />
<br />
System.Windows.Forms.TabPage DynamicTabPage = new TabPage();<br />
<br />
DynamicTabPage.Controls.Add(DynamicPanel);<br />
DynamicTabPage.Location = new System.Drawing.Point(-3, 22);<br />
DynamicTabPage.Padding = new System.Windows.Forms.Padding(3);<br />
DynamicTabPage.Size = new System.Drawing.Size(774, 359);<br />
DynamicTabPage.Text = TabTitle;<br />
DynamicTabPage.UseVisualStyleBackColor = true;<br />
<br />
maDataGridTab.Controls.Add(DynamicTabPage);
<br />
DevAge.ComponentModel.BoundDataView DBSource = new DevAge.ComponentModel.BoundDataView(dynamicDataSet.Tables[dynamicTable].DefaultView);<br />
maDynamicDataGrid.DataSource = DBSource;<br />
maDynamicDataGrid.Name = dynamicTable + "GRID";<br />
ColorOfRows(maDynamicDataGrid.Columns, maDynamicDataGrid);<br />
#endregion<br />
<br />
GroupNamingCtrl = new GroupNaming();<br />
GroupNamingCtrl.RunGetGroupNaming(columnFileToLoad);<br />
<br />
#region //-------------------------------SETS-THE-GROUP-GRID-COLUMNS-------------<br />
int groupCountRow = 0;<br />
int nrOfFixedHeaders = 2;<br />
<br />
maDynamicGroupGrid.Redim(howManyRows + 2, howManyColumns);<br />
maDynamicGroupGrid.FixedRows = nrOfFixedHeaders;<br />
SourceGrid.Grid.MaxSpan = 80;<br />
<br />
for (int header = 0; header < GroupNamingCtrl.infoArrayList.Count; header++)<br />
{<br />
string strConvStartCol = GroupNamingCtrl.StartColArrayList[groupCountRow].ToString();<br />
int intConvStartCol = int.Parse(strConvStartCol);<br />
string srtConvUsesCol = GroupNamingCtrl.UsesColsSArrayList[groupCountRow].ToString();<br />
int intConvUsesCol = int.Parse(srtConvUsesCol);<br />
maDynamicGroupGrid[0, intConvStartCol] = new MyHeader(GroupNamingCtrl.infoArrayList[groupCountRow].ToString());<br />
maDynamicGroupGrid[0, intConvStartCol].ColumnSpan = intConvUsesCol;<br />
groupCountRow++;<br />
}<br />
<br />
int countClos = 0;<br />
foreach (DataColumn DataCom in dynamicDataSet.Tables[dynamicTable].Columns)<br />
{<br />
columnNameString = String.Format(DataCom.ColumnName);
maDynamicGroupGrid[1, countClos] = new MyHeader(columnNameString);<br />
countClos++;<br />
}<br />
<br />
SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell();<br />
<br />
for (int r = nrOfFixedHeaders; r < 1; r++)<br />
{<br />
maDynamicGroupGrid[r, 0] = new SourceGrid.Cells.CheckBox("", false);<br />
<br />
for (int i = 1; i < dynamicDataSet.Tables[0].Columns.Count; i++)<br />
{<br />
string toRemove = dynamicDataSet.Tables[dynamicTable].Columns[i].ColumnName.ToString().Substring(0, 3);<br />
string dbcolumnNameString = dynamicDataSet.Tables[dynamicTable].Columns[i].ColumnName.ToString();
string afterRemove = dbcolumnNameString.Replace(toRemove, "");<br />
<br />
maDynamicGroupGrid[r, i] = new SourceGrid.Cells.Cell(afterRemove, typeof(string));<br />
}<br />
}
#endregion<br />
<br />
maDynamicDataGrid.HScrollPositionChanged += delegate(object s1, SourceGrid.ScrollPositionChangedEventArgs eScr)<br />
{ maDynamicGroupGrid.CustomScrollPosition = maDynamicDataGrid.CustomScrollPosition; };<br />
maDynamicGroupGrid.HScrollBar.Hide();<br />
maDynamicGroupGrid.VScrollBar.Hide();<br />
}
-- modified at 7:30 Tuesday 26th June, 2007
|
|
|
|
|
I have created an enumeration in the class named abc.cs and placed that in the App_Code directory
<br />
public enum MyEnum<br />
{<br />
alfa = 1,<br />
beta = 2,<br />
gamma = 3<br />
};<br />
I have to access this and display in the list control of a webform .
can anyone help me with the corresponding syntax.
i will be thankful to you.
Sebastian
|
|
|
|
|
You should place it within a namespace:
namespace MyProject.MyEnums
{
public enum MyEnum
{
alfa = 1,
beta = 2,
gamma = 3
};
}
then, you should be able to access it anywhere. To get it's value in your aspx, you need a code block:
<%# MyProject.MyEnums.MyEnum.alfa %>
for example.
In your code behind you can put a using statement for the namespace, or access the enum by the full name.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Thank you very much. Everytime you are there to help me.
In this scenario i have to know all the members of the enum. but if i use a file to store the values the updations will reflect in the webpage automatically. is n't it?
is there any better alternatives?
Thanks once again
sebastian
|
|
|
|
|
Im very new in c#, how do i create an application form with labels and text boxes, listbox, submit and clear in either windows forms or console
csanda
|
|
|
|
|
You are definately new. A console app doesn't have labels or text boxes. In fact, doing this is trival, and doesn't even require code. However, before doing this, you should work through a book that teaches C#, and learn the language, on the console. Either way, your question can't be answered in a forum post, you need to buy some sort of C# book and work through it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Hi,
Is there a quick and simple way to get a UML diagram of your classes using Visual C# express? (2k5)
|
|
|
|
|
|
I am not sure in 2k5 but in 2k3 Go to: Project-> Visio UML-> Reverse Engeinner.
I think it may help you
Evil Inside
|
|
|
|
|
Hi,
I wish to set a registry value to record where my programs database was installed.
This folder will change depending on whether it is installed for "Only Me" or "All users".
I know about the [AppDataFolder] and the [CommonAppDataFolder] and can use them but how do i determine which one is to be used so that I can create the relative registry entry?
I tried setting a condition for both/either of them ie ALLUSERS=0 or ALLUSERS=1 but that only results in neither of the registry entries being created.
Thanks,
Glen Harvy
|
|
|
|
|
I'm a Fresher,
I don't know how to create virtual directory... Can anyone explain me how to create?
|
|
|
|