|
|
Hey! I did not get the problem. The event is fired only when it leaves the control.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
I am creating a website where I populate an html table with rows of data that I acquire from a database. For each record in the database, a new row is created in the table with various controls like dropdownboxes, text inputs, buttons, etc. (some are html controls, some are asp controls). Each control is given a unique ID based on the record number/row in the table (ex. btnUpdate_1, btnUpdate_2, etc.). What I am trying to accomplish is, that if the user clicks the Update button (I don't care if the button is an asp or html control), I want to be able to grab the data they entered or changed in the all the other controls in that same row - the dropdownboxes, text inputs, etc. - so that I can then go and update the database. However, I cannot access these controls on the server-side since they are created dynamically and I've tried using some javascript to get the data, but even then, I can only seem to use the data on the client side & am unable to figure out how to use it on the server-side. I hope all this mumble-jumble makes sense. But here is some example code of how the controls are being created...
protected System.Web.UI.WebControls.PlaceHolder plcQ;
private void Page_Load(object sender, System.EventArgs e)
{
string projPath = @"m:Survey\";
Session["myQConn"] = "Provider=MSDASQL/SQLServer ODBC;Driver={Microsoft Visual FoxPro Driver};" + "SourceType=DBF;SourceDB=" + projPath + ";InternetTimeout=300000;Transact Updates=True";
ReadQs(Session["myQConn"].ToString());
}
public void ReadQs(string myConnString)
{
string mySelectQuery = "SELECT * FROM QUESTION";
OdbcConnection myConnection = new OdbcConnection(myConnString);
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myConnection.Open();
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();
plcQ.Controls.Add(new LiteralControl("<table>"));
decimal counter = 0;
string strMin = string.Empty;
string strMax = string.Empty;
string strConfirm = string.Empty;
while (myReader.Read())
{
counter = counter + 1;
strMin = myReader.GetString(2).Trim();
strMax = myReader.GetString(3).Trim();
strConfirm = myReader.GetString(6).Trim();
plcQ.Controls.Add(new LiteralControl("<tr>"));
// Create server-side ASP Update Button
Button btnUpdate = new Button();
btnUpdate.ID = "btnUpdate_" + counter;
btnUpdate.Text = "Update";
btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
// Add button to placeholder
plcQ.Controls.Add(new LiteralControl("<td>"));
plcQ.Controls.Add(btnUpdate);
plcQ.Controls.Add(new LiteralControl("</td>"));
// Add HTML text input boxes to placeholder
plcQ.Controls.Add(new LiteralControl("<td><input type='text' name='minimum_" + counter + "' value='" + strMin + "'></td>"));
plcQ.Controls.Add(new LiteralControl("<td><input type='text' name='maximum_" + counter + "' value='" + strMax + "'></td>"));
// Add HTML drop down box to placeholder
plcQ.Controls.Add(new LiteralControl("<td><select name='confirm_" + counter + "'>"));
if(strConfirm == "T")
plcQ.Controls.Add(new LiteralControl("<option value='T' selected>T</option><option value='F'>F</option></select></td></tr>"));
else
plcQ.Controls.Add(new LiteralControl("<option value='T'>T</option><option value='F' selected>F</option></select></td></tr>"));
}
plcQ.Controls.Add(new LiteralControl("</table>"));
myReader.Close();
myConnection.Close();
}
So, the question is, when the user clicks btnUpdate_3, how do I get whatever they entered in minimum_3 (input text), maximum_3 (input text), and confirm_3 (select) so that I can do an update on my database??? (I have also tried using an html button control, but had the same issues) – HELP!
|
|
|
|
|
hi
I have a datagrid with a two colums. In the first column I have a checkbox in the header (headertemplate) and one for every row(ItemTemplate).
I find the checkbox in the itemtemplate easy with
<br />
cb = (CheckBox) dgi.Cells[0].Controls[1];<br />
but I cant seem to find the checkbox in the header. Ive also tried
<br />
cb = (CheckBox) this.dgOrganisation.FindControl("cbxAlla");<br />
with no results.
How do I find the checkbox?
|
|
|
|
|
Here is one solution:
foreach(DataGridItem dgi in dgOrganisation.Items)
{
if (dgi.ItemType == ListItemType.Header)
{
CheckBox cb = (CheckBox)dgi.Cells[0].Controls[1];
}
}
Haven't tried it out, but it'll do the trick
Hope it helps
Thomas
|
|
|
|
|
Hello, coders, I have a big question. I am gonna make a cd presentation with password protected sections but all my facilities will not have sence if the user browses the cd directory and opens the files there. So is there such a way to forbid browsing the directory in the cd?
|
|
|
|
|
No.
You might be able to mark the directory as hidden and system, then the users with default settings in the explorer won't see it.
You could encrypt the contents of the files. There is build in encryption in the framework.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I want to call a webservice Asynchronously. I know using the Callback mechanism of .NET we can do it.For that we have to add web service in webreference.
But in my application i will not add any Webreference instead i will call webservices through my ForwardRequest method with parameters of webserviceURL,username,password.Here is my code.
public static XmlNode ForwardRequest(string webRequest, string userName, string password)
{
XmlNode resultNode = null;
try
{
WebResponse result = null;
XmlDocument webdoc = new XmlDocument();
string url = "";
string payload = "";
if (webRequest.IndexOf('?') != -1)
{
url = webRequest.Substring(0, webRequest.IndexOf('?'));
payload = webRequest.Substring(webRequest.IndexOf('?') + 1);
}
else
url = webRequest;
WebRequest req = WebRequest.Create(url);
req.Credentials = new NetworkCredential(userName, password);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] SomeBytes = null;
if (payload != null)
{
SomeBytes = Encoding.UTF8.GetBytes(payload);
req.ContentLength = SomeBytes.Length;
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.Length);
newStream.Close();
}
else
{
req.ContentLength = 0;
}
req.Timeout = Timeout.Infinite;
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
webdoc.Load(ReceiveStream);
result.Close();
resultNode = webdoc.DocumentElement;
}
catch (Exception e)
{
}
return resultNode;
}
My question is how should i call webservice Asynchronously with my ForwardRequest(). Can anybody knows how to add callback mechanism of .NET to my ForwardRequest()
Thanks,
Vinoth
|
|
|
|
|
Here is a dotnet Project renamer for c# and VB.NET
http://www.soft4people.net/projectRenamer
and it is free;P...
|
|
|
|
|
Cheap-ass...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi to all,
i'm trying to execute a stored procedure via a web service.
i want to send a struct that contains the parameter of the stored procedure
public struct StoredProcParam
{
public string eParamName;
public SqlDbType eType;
public int eSize;
public ParameterDirection eDirection;
public object eValue;
}
when i create in my windows application an instance of the struct, i can't assign the element of the struct because the debugger consider the element as invalid
localhost.StoredProcParam[] oParam = new localhost.StoredProcParam[3];
oParam[0].eParamName = "@sNomChamp";
oParam[0].eType = localhost.SqlDbType.VarChar;
oParam[0].eSize = 50;
oParam[0].eDirection = localhost.ParameterDirection.Input;
oParam[0].eValue = e.FieldName;
moclsBdd.ExecuteStoredProcedure("sp_UpdatePays", oParam);
does any know how to put values in the elements of the struct and then pass it to the web method in the web service
thanks in advance
fady
|
|
|
|
|
You have to create the structures also:
localhost.StoredProcParam[] oParam = new localhost.StoredProcParam[3];<br />
oParam[0] = new StoredProcParam();<br />
oParam[1] = new StoredProcParam();<br />
oParam[2] = new StoredProcParam();
---
b { font-weight: normal; }
|
|
|
|
|
thanks a lot for your reply, it works very good.
i were badly stuck with this issue
thanks again,
fady
|
|
|
|
|
Hi and thanks to your reply, it works very good
i was badly stuck with this issue
thanks again
fady
|
|
|
|
|
Can i add a reference to them and include the Dll's with the app?
If so does anybody know exactly what dll's 'n' stuff that i will need?
Update: the message says "File or assembly name Microsoft.DirectX, or one of its dependencies, was not found."
|
|
|
|
|
That depends on which .DLL's your talking about. The DirectX .DLL's will have to be installed using the Redistributable installer. The Managed DirectX Interop .DLL's you can include with your app. These are the .DLL's you should be setting your reference to. You haven't done this judging by the error message you posted.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
|
Hello,
Is there a way to show an MDIChild form modally?
Thank you very much
|
|
|
|
|
No. MDI Child forms are not meant for this purpose.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So if my MDIChild window open, how can I make shure they don't click
on the menu, etc.. without disabling it. So to make it the same
way as when you trying to click away in the modal form and it makes this
"Ding" sound?
Thank you
|
|
|
|
|
zaboboa wrote:
how can I make shure they don't click
on the menu, etc.. without disabling it.
"menu, etc, ..." of what? Your explanation isn't very clear at all.
An MDI Child window is a Multiple DOCUMENT Interface window. It's meant to edit documents, like having multiple editing windows open in Word, each editing a different document. It's not meant to be a modal window for anything.
I don't get why your MDI Child window has to be modal. I can't think of a single reason why you would want to do this.
What are you trying to do with this?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
you can't make it a modal but you can play a trick like I did. Do not make it a MdiChild. Set its ShowInTaskBar to false.. open it modally.. (ShowDialog) that will do exactly what you want..
Regards
|
|
|
|
|
how do i map tablestyle to dataview? ..its easy with dataset table names,
or how do i fill dataset table with dataview..
bye
|
|
|
|
|
Hello all,
I have a winform which I want to hide just after the InitializeComponent method is called.
I tried using Hide() to no avail.
Any insights?
Thanks.
Alberto Bar-Noy
Software Engineer
http://www.certagon.com
|
|
|
|