|
Hi
Thanks for your suggestion but i need to get at runtime, this case i m not getting it.
Regards,
Naren.
narendra
|
|
|
|
|
Hi everybody.
I have a project which is developed by visual c#.net by visual studio 2005.
It is a database project and because of damaging the connection in anywhere of my application, I put the main method in try catch block which handles SqlException.
When I run the application, the try catch code works. But when I execute my application exe, the try catch code does not work. And unhandled exception message is shown and says to handle SqlException exception. I really get confused what to do...
My code in visual studio running mode, works but when executing the exe file, it does not work. I think it is the worst error for programmers.
Please help me with my stupid problem.
Thanks
Rastgar
|
|
|
|
|
Hello All!
I have a richtextbox such that the user can copy-paste images into it. Now i am saving the 'rtf' of richtextbox in the database. Now after retrieving the 'rtf' and assigning it to Richtextbox, the image doesnt show up.
It is to be noted that the rtf before storing and after retrieving is the same.
Thanx in advance
regards
_mubashir
|
|
|
|
|
Hi!
From time to time visual studio 2005 shows a queer error message:
'Code generation for property 'Cursor' failed. Error was: ''CursorConverter' is unable to convert 'System.Windows.Forms.Cursor' to 'System.ComponentModel.Design.Serialization.InstanceDescriptor'.'
Maybe it happens because i use an own UserControl. But in fact this UserControl doesn't make anything with the property cursor ...
Is there anybody who knows this error message and can say what's wrong!?!?
Thanks in advance!
-- modified at 4:26 Tuesday 9th May, 2006
|
|
|
|
|
As far as I can tell, this seems to be a bug in Visual Studio (still present in VS 2008).
A workaround that worked for me was to mark the property with an attribute to make it invisible
to the designer, as follows:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Cursor MyCursor{ get; set; }
|
|
|
|
|
Cool! A response after more than three years
I thought I am the only one who has this problem, so I've learned to live with this Bug. But now I will try this workaround.
Many thanks!
occcy
|
|
|
|
|
Got my CustomRowEvent working..
able to fill my textboxes in my new form.
but i think it's not the fastest or best way.
i now use this line of code :
t075_BORGTOCHTNUMMER_1TextBox.Text = Grid["t075BORGTOCHTNUMMER1DataGridViewTextBoxColumn", RowIndex].Value.ToString();<br />
this work just great.. really..
BUT...
if you got about.. 60 textboxes.. it's kinna like a lot of work..
so i was thinking..
if i change my fill command with something like this..:
<br />
this.dBANBM_T075_BORGTOCHTTableAdapter.Fill(testdb1DataSet, Grid, RowIndex);<br />
he give's me the error that Grid and RowIndex does not excist in my current contex..
however..
i use the following code
<br />
public dborgtocht(testdb1DataSet DSet, DataGridView Grid, int RowIndex)<br />
{<br />
InitializeComponent();<br />
PopulateTextBoxes(testdb1DataSet, Grid, RowIndex);<br />
}<br />
so you really should think that he should be able to find them..
hope i explained enough now.
|
|
|
|
|
how can i define an array in c# and give it value?
|
|
|
|
|
|
int [] abc = new int[20]; where 20 is array length
or
int [] xyz = {1, 2, 123, 54, 67, 324}; //here you have defined constant array
in first case u can set array value by
abc[0] = 1;
abc[1] = 2;
abc[2] = 123;
Shajeel
|
|
|
|
|
I am doing a network application that involves DataTables transfer over the network, is there some way to convert the DataTable to an array of bytes to be transfered or even a way to transfer the whole DataTable through the socket layer without worrying about the underlying procedures.
Thanks in advance.
|
|
|
|
|
Can u pls tell me, wether following SQL string format is correct or not.
textWord.text,comboCat.text are string variables of C#.
indexInCategoryTable and SubCategoryNo are integer variables.
"select * from Words where
word = N'"+textWord.Text+"' and
CategoryTableName = '"+comboCat.Text+"' and
IndexInCategoryTable = 'indexInCategoryTable' and
SubCategoryNo = 'SubCategoryNo'";
|
|
|
|
|
No it is not, because your string values you are concatenating into the sql string but your integer values are not.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
Can U Pls modify the above Query to make it correct.
|
|
|
|
|
Dear Friands,
I have two overloaded methods with the following signatures in 'MyClass' that is a class library in a dll file and I want to invoke a method from this dll at runtime by reflection:
public class MyClass()
{
public int MyMethod(ref int intParam)
{
intParam += 100;
return Math.Sin(intParam);
}
public int MyMethod(int intParam)
{
intParam += 100;
return Math.Sin(intParam);
}
}
When I use typeof(MyClass).GetMethod("MyMethod"); ,System.Reflection.AmbiguousMatchException is throw !!
If I use
typeof(MyClass).GetMethod("MyMethod",new Type [] {typeof(int)});
The second overloaded method with the value parameter invokes.
How can I force the CLR to run the first method and pass the parameter to it by reference ?
Regards,
Xironix
[ _ Always there is another way _ ]
|
|
|
|
|
Hi all, I am creating a text mining engine and after a button click i create inverted index and it takes quite a while to do so. Now i want some user interface to tell that something is in progress. i am using a static label lblStatus. and updating its value during different places in the function. but it doesnt work..
lblStatus.Text = "10% Completed";
and so on. but it is not working the label doesnot change it remain the same as it was in the start and when the index is completely created it shows 100% completed....
tell me how it will work.. or advise me wat other method should i use.
Regards,
|
|
|
|
|
Use
Application.DoEvents();
|
|
|
|
|
Sir plzz explain a little coz i m relative new commer in C#
Regards,
|
|
|
|
|
If you call DoEvents in your code, your application can handle the other events.
Say, you are are updating the label text by 10% within a function. You wont be able to see updated label text messages until the function has completed its execution. If you use Application.DoEvents() just after the update ui code, the function will continue its execution and you UI will be updated
label1.Text="20% completed";
Application.Doevents();
Have a look into this link
http://msdn2.microsoft.com/en-US/library/system.windows.forms.application.doevents.aspx
|
|
|
|
|
thxx Sir,
it is working exactly as i wanted it to
Regards,
-- modified at 11:21 Tuesday 9th May, 2006
|
|
|
|
|
I am creating a deployment project. I have used custom action, and installing database. Username and password will be get from user. I also edited password character as * using Orca. But i dont know how to set msiHiddenProperties for the password. Even though the password is *, The parameter shows the password and also in log file. How to hide the parameters and user entered text in log file. and also how to use verbose log method
my email id: haikumars@gmail.com
Thanks
KumarShanmugam
|
|
|
|
|
Hi to all.
I'm using the below given code to connect the interfaces rowprovider and row consumer,
the Row provider, doesnt get connected with Row consumer
CODE FOR ROW CONSUMER
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebPartPages.Communication;
using System.Data;
using System.Runtime.InteropServices;
namespace MyWebParts
{
///
/// Summary description for RowConsumer.
///
[GuidAttribute("66C28F7F-9B1E-4ba4-B16F-FCF391088C57")]
[ToolboxData("<{0}:RowConnectedConsumer runat=server>")]
public class RowConnectedConsumer : WebPart, IRowConsumer
{
//Used to keep track of whether or not the connection will be running client-side
private bool _runAtClient = false;
//Keep a count of IRow connections
private int _rowConnectedCount = 0;
//Web Part UI
private DataGrid _dataGrid;
///
///----Notification to the Web Part that is should ensure that all
///----its interfaces are registered using RegisterInterface.
///
public override void EnsureInterfaces()
{
//Register the IRowConsumer interface
RegisterInterface("MyRowConsumerInterface_WPQ_", //InterfaceName: Friendly name of the interface
"IRowConsumer", //InterfaceType: The type of the interface
WebPart.UnlimitedConnections, //MaxConnections: sets how many connections can
//be formed on this interface
ConnectionRunAt.ServerAndClient, //RunAtOptions: where the interface can be run
this, //InterfaceObject: reference to the actual
//object that implements this interface
"RowConsumerInterface_WPQ_", //InterfaceClientReference: for client-side connections, a
//string that is used as the identifier for the client-side
//object that implements this interface
"MyRowConsumer", //MenuLabel: a general label for the interface
//(used in Authoring Connections)
"Just a simple IRowConsumer"); //Description: an extended explanation of the
//interface (used in Authoring Connections)
}
///
///----Called by the framework to determine whether a part thinks
///----that it can be run on the client or server based on the current
///----configuration.
///
public override ConnectionRunAt CanRunAt()
{
//This Web Part can run on both the client and the server
return ConnectionRunAt.ServerAndClient;
}
///
///----Notification to the Web Part that it has been connected. The
///----framework uses this to inform a part that it is connected as
///----soon as it connects up the appropriate events for the connection.
///
public override void PartCommunicationConnect(string interfaceName,
WebPart connectedPart,
string connectedInterfaceName,
ConnectionRunAt runAt)
{
//Check if this is my particular cell interface
if (interfaceName == "MyRowConsumerInterface_WPQ_")
{
//Keep a count of the connections
_rowConnectedCount++;
}
//Check to see if this is a client-side part
if (runAt == ConnectionRunAt.Client)
{
//This is a client-side part
_runAtClient = true;
return;
}
//Must be a server-side part so need to create the Web Part's controls
EnsureChildControls();
}
//PartCommunicationInit and PartCommunicationMain are not needed in this case for the Consumer,
//because the Consumer doesn't have any events that it needs to fire
//during either of these phases.
//GetInitArgs is not needed in this case because IRowConsumer never
//requires a transformer
//PartCommunicationNeedData, BeginDataRetrieval, and EndDataRetrieval are not
//needed for this Web Part because it doesn't have to do any asynchronous
//data fetching.
///
/// The RowProviderInit event handler.
/// The Provider part will fire this event during its PartCommunicationInit phase
///
public void RowProviderInit(object sender, RowProviderInitEventArgs rowProviderInitArgs)
{
//This is where the Consumer part could see what type of "Row" the Provider
//will be sending.
//Need to ensure that all of the Web Part's controls are created
EnsureChildControls();
//Need to add the columns to the DataGrid source table
for(int i = 0; i <= rowProviderInitArgs.FieldList.GetUpperBound(0); i++)
{
// Add a column object to the table
DataColumn dataColumn = new DataColumn();
dataColumn.ColumnName = rowProviderInitArgs.FieldList[i];
if(rowProviderInitArgs.FieldDisplayList != null)
{
dataColumn.Caption = rowProviderInitArgs.FieldDisplayList[i];
}
((DataTable)_dataGrid.DataSource).Columns.Add(dataColumn);
}
//Bind the data grid
_dataGrid.DataBind();
}
///
/// The RowReady event handler.
/// The Provider part will fire this event during its PartCommunicationMain phase
///
/// <param name="sender" />Provider Web Part
/// <param name="rowReadyArgs" />The args passed by the Provider
public void RowReady(object sender, RowReadyEventArgs rowReadyArgs)
{
//Add the Rows that were passed by the Provider to the DataGrid's
//source table
if(rowReadyArgs.Rows != null)
{
if(rowReadyArgs.Rows[0] != null)
{
for(int i = 0; i <= rowReadyArgs.Rows.GetUpperBound(0); i++)
{
object[] rowItems = rowReadyArgs.Rows[i].ItemArray;
DataRow dr = ((DataTable)_dataGrid.DataSource).NewRow();
dr.ItemArray = rowItems;
((DataTable)_dataGrid.DataSource).Rows.Add(dr);
}
///
/// Render this Web Part control to the output parameter specified.
///
/// <param name="output" /> The HTML writer to write out to
protected override void RenderWebPart(HtmlTextWriter output)
{
//Need to ensure that all of the Web Part's controls are created
EnsureChildControls();
//Is it connected?
if(_rowConnectedCount > 0)
{
//Render client connection code if the connection is client-side
if (_runAtClient)
{
output.Write(ReplaceTokens(" Connected: Client-Side "
+ "\n"
+ "Field List: \n"
+ "Field Display List: \n"
+ " function Consumer_WPQ_()\n"
+ " {\n"
+ " this.RowProviderInit = RowProviderInit_WPQ_;\n"
+ " this.RowReady = RowReady_WPQ_;\n"
+ " }\n"
+ " function RowProviderInit_WPQ_(sender, rowProviderInitArgs)\n"
+ " {\n"
+ " var adBSTR = 8;\n"
+ " var columnCount;\n"
+ " if(rowProviderInitArgs.FieldDisplayList != null)\n"
+ " {\n"
+ " columnCount = rowProviderInitArgs.FieldDisplayList.length;\n"
+ " rowFieldNames_WPQ_ = rowProviderInitArgs.FieldDisplayList;\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " columnCount = rowProviderInitArgs.FieldList.length;\n"
+ " rowFieldNames_WPQ_ = rowProviderInitArgs.FieldList;\n"
+ " }\n"
+ " document.all(\"FieldList_WPQ_\").innerHTML = \"Field List: \";\n"
+ " document.all(\"FieldDisplayList_WPQ_\").innerHTML = \"Field Display List: \";\n"
+ " if(rowProviderInitArgs.FieldList != null)\n"
+ " {\n"
+ " for(var i = 0; i < rowProviderInitArgs.FieldList.length; i++)\n"
+ " {\n"
+ " document.all(\"FieldList_WPQ_\").innerHTML += rowProviderInitArgs.FieldList[i] + \";\";\n"
+ " }\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " document.all(\"FieldList_WPQ_\").innerHTML += \"NULL\";\n"
+ " }\n"
+ " if(rowProviderInitArgs.FieldDisplayList != null)\n"
+ " {\n"
+ " for(var i = 0; i < rowProviderInitArgs.FieldDisplayList.length; i++)\n"
+ " {\n"
+ " document.all(\"FieldDisplayList_WPQ_\").innerHTML += rowProviderInitArgs.FieldDisplayList[i] + \";\";\n"
+ " }\n"
+ " }\n"
+ " else\n"
+ " {\n"
+ " document.all(\"FieldDisplayList_WPQ_\").innerHTML += \"NULL\";\n"
+ " }\n"
+ " RenderTable_WPQ_(null, true);\n"
+ " }\n"
+ " function RowReady_WPQ_(sender, rowReadyArgs)\n"
+ " {\n"
+ " RenderTable_WPQ_(rowReadyArgs.Rows, false);\n"
+ " document.all('DataTable_WPQ_').innerHTML += 'SelectionStatus: ' + rowReadyArgs.SelectionStatus + ' ';\n"
+ " }\n"
+ " function RenderTable_WPQ_(dataTable, emptyTable)\n"
+ " {\n"
+ " tableHTML = '';\n"
+ " for(var i = 0; i < rowFieldNames_WPQ_.length; i++)\n"
+ " {\n"
+ " tableHTML += '';\n"
+ " }\n"
+ " tableHTML += '';\n"
+ " if(!emptyTable)\n"
+ " {\n"
+ " if(!dataTable.EOF || ! dataTable.BOF)\n"
+ " {\n"
+ " var columnCount = dataTable.Fields.Count;\n"
+ " dataTable.MoveFirst();\n"
+ " do\n"
+ " {\n"
+ " tableHTML += '';\n"
+ " for(var i = 0; i < columnCount; i++)\n"
+ " {\n"
+ " tableHTML += '';\n"
+ " }\n"
+ " tableHTML += '';\n"
+ " dataTable.MoveNext();\n"
+ " }\n"
+ " while(!dataTable.EOF);\n"
+ " }\n"
+ " }\n"
+ " tableHTML += '';\n"
+ " tableHTML += rowFieldNames_WPQ_[i];\n"
+ " tableHTML += ' |
---|
';\n"
+ " tableHTML += dataTable.Fields(i).Value;\n"
+ " tableHTML += ' | ';\n"
+ " document.all('DataTable_WPQ_').innerHTML = tableHTML;\n"
+ " }\n"
+ "//-->\n"
+ "\n"));
}
else
{
//Just render some informational text
output.RenderBeginTag(HtmlTextWriterTag.Br);
output.RenderEndTag();
output.RenderBeginTag(HtmlTextWriterTag.H5);
output.Write("Connected Server-Side");
output.RenderEndTag();
output.RenderBeginTag(HtmlTextWriterTag.Br);
output.RenderEndTag();
//Render the DataGrid control
_dataGrid.RenderControl(output);
}
}
else
{
//There wasn't a row connection formed,
//so just output a message
output.Write("NO ROW INTERFACE CONNECTION");
}
}
///
/// Create all of the controls for this Web Part
///
protected override void CreateChildControls()
{
//Create the DataGrid
_dataGrid = new DataGrid();
//Create the DataTable
DataTable dataTable = new DataTable();
//Set the DataGrid's DataSource
_dataGrid.DataSource = dataTable;
_dataGrid.ID = "DataGrid";
}
}
}
CODE FOR ROW PROVIDER
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebPartPages.Communication;
using System.Data;
namespace MyWebParts
{
///
/// Summary description for WebCustomControl1.
///
[ToolboxData("<{0}:RowConnectedWP runat=server>")]
[GuidAttribute("0E01E611-EDC3-4098-AC5D-5526E35F56F1")]
public class RowConnectedWP : WebPart, IRowProvider
{
//RowProviderInit Event
public event RowProviderInitEventHandler RowProviderInit;
//RowReady Event
public event RowReadyEventHandler RowReady;
//Used to keep track of whether or not the connection will be running client-side
private bool _runAtClient = false;
//Keep a count of IRow connections
private int _rowConnectedCount = 0;
//Web Part UI
private Button _rowButton;
private DataGrid _dataGrid;
//Row information
private string[] _rowFieldNames;
private string[] _rowFieldDisplayNames;
//Used to keep track of whether or not the Button in the Web Part was clicked
private bool _rowButtonClicked = false;
///
///----Notification to the Web Part that is should ensure that all
///----its interfaces are registered using RegisterInterface.
///
public override void EnsureInterfaces()
{
//Register the IRowProvider interface
RegisterInterface("MyRowProviderInterface_WPQ_", //InterfaceName: Friendly name of the interface
"IRowProvider", //InterfaceType: The type of the interface
WebPart.UnlimitedConnections, //MaxConnections: sets how many connections can
//be formed on this interface
ConnectionRunAt.ServerAndClient, //RunAtOptions: where the interface can be run
this, //InterfaceObject: reference to the actual
//object that implements this interface
"RowProviderInterface_WPQ_", //InterfaceClientReference: for client-side connections, a
//string that is used as the identifier for the client-side
//object that implements this interface
"MyRowProvider", //MenuLabel: a general label for the interface
//(used in Authoring Connections)
"Just a simple IRowProvider"); //Description: an extended explanation of the
//interface (used in Authoring Connections)
}
///
///----Called by the framework to determine whether a part thinks
///----that it can be run on the client or server based on the current
///----configuration.
///
public override ConnectionRunAt CanRunAt()
{
//This Web Part can run on both the client and the server
return ConnectionRunAt.ServerAndClient;
}
///
///----Notification to the Web Part that it has been connected. The
///----framework uses this to inform a part that it is connected as
///----soon as it connects up the appropriate events for the connection.
///
public override void PartCommunicationConnect(string interfaceName,
WebPart connectedPart,
string connectedInterfaceName,
ConnectionRunAt runAt)
{
//Check if this is my particular cell interface
if (interfaceName == "MyRowProviderInterface_WPQ_")
{
//Keep a count of the connections
_rowConnectedCount++;
}
//Check to see if this is a client-side part
if (runAt == ConnectionRunAt.Client)
{
//This is a client-side part
_runAtClient = true;
return;
}
//Must be a server-side part so need to create the Web Part's controls
EnsureChildControls();
}
///
///----At this time, a part should fire any events that end with 'Init'
///----if they can.
///
public override void PartCommunicationInit()
{
//If the connection wasn't actually formed then don't want to send Init event
if(_rowConnectedCount > 0)
{
//If there is a listener, send init event
if (RowProviderInit != null)
{
//Need to create the args for the RowProviderInit event
RowProviderInitEventArgs rowProviderInitArgs = new RowProviderInitEventArgs();
//Set the FieldNames
rowProviderInitArgs.FieldList = _rowFieldNames;
//Set the FieldDisplayNames
rowProviderInitArgs.FieldDisplayList = _rowFieldDisplayNames;
//Fire the RowProviderInit event.
//This basically tells the Consumer Web Part what type of
//DataRow it will be receiving when RowReady is fired later.
RowProviderInit(this, rowProviderInitArgs);
}
}
}
///
///----A part can fire any events that it wants to in Main.
///
public override void PartCommunicationMain()
{
//If the connection wasn't actually formed then don't want to send Ready event
if(_rowConnectedCount > 0)
{
//If there is a listener, send RowReady event
if (RowReady != null)
{
//Need to create the args for the RowProviderInit event
RowReadyEventArgs rowReadyArgs = new RowReadyEventArgs();
//If user clicked button then send the value
if (_rowButtonClicked)
{
//Need to generate the array of DataRow(s) from the
//DataGrid's DataSource
DataRow[] dr = new DataRow[1];
dr[0] = ((DataTable)_dataGrid.DataSource).Rows[0];
//Set the Rows to the value of the first row in the DataGrid
//This is the value that will be sent to the Consumer
rowReadyArgs.Rows = dr;
//Set the SelectionStatus value
rowReadyArgs.SelectionStatus = "Standard";
}
else
{
//The user didn't actually click the button
//so just send a null DataRow to the Consumer
DataRow[] dr = new DataRow[1];
dr[0] = null;
rowReadyArgs.Rows = dr;
//Set the SelectionStatus value
rowReadyArgs.SelectionStatus = "None";
}
//Fire the RowReady event.
//The Consumer will then receive the DataRow array
RowReady(this, rowReadyArgs);
}
}
}
///
///----The GetInitArgs method is called by the Authoring environment for all
///-----the initial data required for creating a connection. It is a virtual
///-----method on the WebPart base class which needs to be overridden by the
///-----developer. The method returns the InitArgs object and takes in the
///-----interface name.
///
public override InitEventArgs GetInitEventArgs(string interfaceName)
{
//Check if this is my particular cell interface
if (interfaceName == "MyRowProviderInterface_WPQ_")
{
EnsureChildControls();
//Need to create the args for the RowProviderInit event
RowProviderInitEventArgs rowProviderInitArgs = new RowProviderInitEventArgs();
//Set the FieldList
rowProviderInitArgs.FieldList = _rowFieldNames;
//Set the FieldDisplayNames
rowProviderInitArgs.FieldDisplayList = _rowFieldDisplayNames;
//return the InitArgs
return(rowProviderInitArgs);
}
else
{
return(null);
}
}
//PartCommunicationNeedData, BeginDataRetrieval, and EndDataRetrieval are not
//implemented for this Web Part because it doesn't have to do any asynchronous
//data fetching.
///
/// Render this Web Part control to the output parameter specified.
///
protected override void RenderWebPart(HtmlTextWriter output)
{
//Need to ensure that all of the Web Part's controls are created
EnsureChildControls();
//Is it connected?
if(_rowConnectedCount > 0)
{
//Render client connection code if the connection is client-side
if (_runAtClient)
{
output.Write(ReplaceTokens(" Connection: Client-Side "
+ "\n"
+ "Fire checked rows\n"
+ "\n"
+ " \n"
+ " \n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n")
);
}
else
{
//Just render some informational text
output.RenderBeginTag(HtmlTextWriterTag.Br);
output.RenderEndTag();
output.Write("Connected: Server-Side");
output.RenderBeginTag(HtmlTextWriterTag.Br);
output.RenderEndTag();
//Render the DataGrid control
_dataGrid.RenderControl(output);
//Render the Button
_rowButton.RenderControl(output);
}
}
else
{
//There wasn't a row connection formed,
//so just output a message
output.Write("NO ROW INTERFACE CONNECTION");
}
}
///
/// Create all of the controls for this Web Part
///
protected override void CreateChildControls()
{
//Create the Button
_rowButton = new Button();
_rowButton.ID = "RowButton";
_rowButton.Text = "Fire RowReady";
Controls.Add(_rowButton);
//Create the DataGrid
_dataGrid = new DataGrid();
//Create the DataTable
DataTable dataTable = new DataTable();
// Add three column objects to the table.
DataColumn idColumn = new DataColumn();
idColumn.DataType = System.Type.GetType("System.Int32");
idColumn.ColumnName = "id";
idColumn.Caption = "ID";
idColumn.AutoIncrement = true;
dataTable.Columns.Add(idColumn);
DataColumn fNameColumn = new DataColumn();
fNameColumn.DataType = System.Type.GetType("System.String");
fNameColumn.ColumnName = "FName";
fNameColumn.Caption = "First Name";
dataTable.Columns.Add(fNameColumn);
DataColumn lNameColumn = new DataColumn();
lNameColumn.DataType = System.Type.GetType("System.String");
lNameColumn.ColumnName = "LName";
lNameColumn.Caption = "Last Name";
dataTable.Columns.Add(lNameColumn);
DataColumn ageColumn = new DataColumn();
ageColumn.DataType = System.Type.GetType("System.Int32");
ageColumn.ColumnName = "Age";
ageColumn.Caption = "Age";
dataTable.Columns.Add(ageColumn);
// Once a table has been created, use the NewRow to create a DataRow.
DataRow dataRow;
dataRow = dataTable.NewRow();
// Then add the new row to the collection.
dataRow["FName"] = "Gabrielle";
dataRow["LName"] = "Viso";
dataRow["Age"] = 7;
dataTable.Rows.Add(dataRow);
//Add a second row
dataRow = dataTable.NewRow();
// Then add the new row to the collection.
dataRow["FName"] = "Christina";
dataRow["LName"] = "Viso";
dataRow["Age"] = 4;
dataTable.Rows.Add(dataRow);
//And a third
dataRow = dataTable.NewRow();
// Then add the new row to the collection.
dataRow["FName"] = "Tom";
dataRow["LName"] = "Rizzo";
dataRow["Age"] = 30;
dataTable.Rows.Add(dataRow);
//And a fourth
dataRow = dataTable.NewRow();
// Then add the new row to the collection.
dataRow["FName"] = "Stacy";
dataRow["LName"] = "Eckstein";
dataRow["Age"] = 30;
dataTable.Rows.Add(dataRow);
//And a fifth
dataRow = dataTable.NewRow();
// Then add the new row to the collection.
dataRow["FName"] = "Susan";
dataRow["LName"] = "Rizzo";
dataRow["Age"] = 34;
dataTable.Rows.Add(dataRow);
//Set the DataGrid's DataSource
_dataGrid.DataSource = dataTable;
_dataGrid.ID = "DataGrid";
_dataGrid.Attributes.Add("WDFLibID", "ServerSideRowProvider_DataGrid");
_dataGrid.DataBind();
//Set the DataTable FieldName information.
//This information will be passed to the Consumer by
//firing the RowProviderInit event.
int columnCount = dataTable.Columns.Count;
_rowFieldNames = new string[columnCount];
_rowFieldDisplayNames = new string[columnCount];
for(int i = 0; i < columnCount; i++)
{
_rowFieldNames[i] = dataTable.Columns[i].ColumnName;
_rowFieldDisplayNames[i] = dataTable.Columns[i].Caption;
}
_rowButtonClicked = false; // Initialize to false -- user hasn't clicked yet
_rowButton.Click += new EventHandler(RowButtonClicked); // Rowen for Button's click event
}
///
/// The Button OnClick event handler
///
/// <param name="sender" />The Button object
/// <param name="e" />The Event Arguments
private void RowButtonClicked(object sender, EventArgs e)
{
_rowButtonClicked = true; //user clicked button, set to true
}
}
}
|
|
|
|
|
Good grief why did you post that entire mess? couldn't you have narrowed it down the problematic portion of the code?
What is with all the string concatenation garbage? Is this production code or some class assignment? Aren't there classes that help generate Javascript code? At lease use a StringBuilder.
Please someone tell me that this is not reflective of the normal state of web development today!
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
|
hello all.
please help me on this error "Failed to access IIS metabase. " this error comes when i run a aspx page build in asp.net 2.0 version.
-- modified at 0:24 Tuesday 9th May, 2006
|
|
|
|
|