|
What is the data type of the field? The "D" specifier will only work with integral types.
---
b { font-weight: normal; }
|
|
|
|
|
I'm not sure what type results from the DataBinder statement? Evidently it's not a String or Decimal. But, I see what you mean now that I found "Standard Numeric Format Strings" item in the MSDN doc. I circumvented the issue by using the Fixed format instead. Some time when I'm not under the gun I'll have to follow up and figure this one out. Thanks.
|
|
|
|
|
The DataBinder returns a value of the type Object, but the real type of the value depends on the data type of the source. If you for example have a int field in the data base, the object contains an Int32 value.
---
b { font-weight: normal; }
|
|
|
|
|
Hello There!
I have a usercontrol named A that displays data from a database. I create a dynamic number of usercontrols depending on the number of hits from the database given a certain critera. If I receive 4 datasets from the database I create 4 usercontrols and so on…
These Usercontrols contains repeater objects displaying the data aswell as a button that interact with the data. Im now experiencing some major problems to get these buttons to fire once pressed.
I do believe I have done it the right way.
Usercontrol A
1. Initialize
2. declare Click method
<br />
private void InitializeComponent()<br />
{<br />
this.OpenButton.Click += new System.EventHandler(this.Open_Click);<br />
this.Load += new System.EventHandler(this.Page_Load);<br />
}
protected void OpenButton_Click(object sender, System.EventArgs e)<br />
{<br />
}
It works perfect using static usercontrols, but not in this dynamic case. It wont even enter the OpenButton_click method in debug mode.
Is the EventHandler passing the event to the main app or what is happening.?!? Nothing what so ever happens..
Please help me Experts-Number-One, you are my only hope….
/Peter
|
|
|
|
|
See,
Recall that the framework create the controls tree only for static controls - this is why the event of the dynamic controls could not reached there targets when the page is posted back - so this is your job, as i describe in a minute.
The problem is that the page controls tree is built before the page load - and events that should be fired target to controls resolved in that stage. Hence if your dynamic controls are not existed in this level - WITH THE SAME ID AS THEY HAD IN THE PREVIOUS POSTBACK - the events will not be fired.
So, a good solution will be:
1 - When you create the controls assigned them a unique id. Aparantly you will do it in the Page_Load, you should do it only if the page was not post bask. Dont forget to add you controls to the Controls Collection of their container. For example - if you add these controls directly on the form - Write: Page.Controls.Add(...your control here).
Page_load...
- if not post back
- Create the control
- Assigned the created control a unique id
- Add the created control to its container "Controls" collection.
2 - When you create these controls - put some information in the ViewState so you can rebuild these controls when the page will be posted-back:
- ViewState[some key]=information.
The information should be encoded in a way that can describe you in the next step what controls were existed before the post back.
3 - Override the TrackViewState method of the page and rebuild the dynamic part of your page using the information you saved in the ViewState. Again dont forget to add these dynamic created controls to your Controls collection.
That is all!
If the dynamic controls that you are creating are always the same (obviously they are not) you could be satisfied with the Page_Load part without checking the PostBack status.
Best regards,
e-laj
|
|
|
|
|
Good comment. I have not tried yet but it give me alot information.
Thanks so much.
|
|
|
|
|
Thanks for the reply and detailed answer e-laj!
I have been away for a couple of days so I havn't been able to reply until now. Anyway I have made some progress:
1. I load the controls in Page_Load and assign them unique ids within
not PagePostBack.
2. I put the control into the viewstate (to load when page is post back)
The events wont fire the first time but the second time they do.
It still seems to be something wiht the lifecycle.
Could you explain some more about the TrackViewState?
<br />
if(!Page.IsPostBack) <br />
{<br />
<br />
RequestDataFromPostMessage();<br />
<br />
Domain [] domainCollection = GetInformationFromWebSevice()<br />
<br />
<br />
domains=domainCollection.Length;<br />
ViewState["domains"]=domains;<br />
DomainControls = new DomainControl[domains];<br />
<br />
for(int i=0;i domains;i++) <br />
{<br />
DomainControls[i]=(DomainControl)LoadControl "DomainControl.ascx");<br />
<br />
<br />
DomainControls[i].InitSubDomainData(.......);<br />
<br />
<br />
DomainControls[i].ID=i.ToString();<br />
Session["DomainControl"+i.ToString()]=(Control)DomainControls[i];<br />
placeHolder1.Controls.Add(DomainControls[i]);<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
else <br />
{<br />
domains = (int)ViewState["domains"];<br />
DomainControl dControl = new DomainControl();<br />
for(int i=0;i<domains;i++) <br />
{<br />
dControl = (DomainControl)Session["DomainControl"+i.ToString()];<br />
placeHolder1.Controls.Add(dControl); <br />
}<br />
<br />
}<br />
The debugger crahses in the Onclick event method in the usercontrol while debugging.
protected void Open_Click(object sender, System.EventArgs e) {<br />
....do something<br />
}<br />
Any suggestions?
Thanks!
|
|
|
|
|
Sorry - I have a little mistake, well i implement dynamic control creation long time ago - i forgot an important point.
You should override the LoadViewState instead of TrackViewState.
The TrackViewState is executed before the view state is populated with the previous value, LoadViewState is the right point to initialize dynamic controls according to view state values - in this point the view state has its previous values.
Here is a full running example. In this example you can create dynamic buttons and executes their events.
I wrote this example for you and any other who may need it.
The DynamicExample.aspx
=======================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynamicExample.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="buttonCreateButtons" runat="server" OnClick="buttonCreateButtons_Click" Text="Create" /> <asp:TextBox ID="textBoxTotalButtons" runat="server" Width="53px"></asp:TextBox> buttons<br />
<br />
<asp:Panel ID="panelButtons" runat="server" Height="85px" Width="319px">
</asp:Panel>
<br />
Click Message:<br />
<asp:Label ID="labelClickMessage" runat="server" BackColor="#80FF80" Height="25px" Width="325px"></asp:Label><br />
<br />
Command Message:<br />
<asp:Label ID="labelCommandMessage" runat="server" Height="25px" Width="325px" BackColor="#80FF80"></asp:Label><br />
<br />
</div>
</form>
</body>
</html>
The DynamicExample.aspx.cs
==========================
/*******************************************************************************
*
* Filename: DynamicExample.cs
*
* Class: DynamicExample
*
* Creation Date: 06/Oct/2006
*
* Update list:
* -----------
* 1) Date:
* Description:
*
* Writer: Ilan Amoyal (e-laj)
*
******************************************************************************/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// Loads the view state - and initializes dynamic controls according to the view state.
/// </summary>
/// <param name="savedState">The saved state.</param>
protected override void LoadViewState(object savedState)
{
/* Call the base calss implementation */
base.LoadViewState(savedState);
/* Create any dynamic */
/* Recall the int? is .NET 2 nulleable integer */
int? totalButtons = (int?)ViewState["totalDynamicButtons"];
if(totalButtons != null)
{
CreateDynamicButtons((int)totalButtons);
}
}
/// <summary>
/// Creates dynamic buttons.
/// </summary>
/// <param name="totalButtonToBeCreated">The total number of buttons to be created.</param>
private void CreateDynamicButtons(int totalButtonToBeCreated)
{
/* Removes any previous buttons */
panelButtons.Controls.Clear();
for(int i = 1; i <= totalButtonToBeCreated; i++)
{
CreateDynamicButton(i);
}
/* Save the number of buttons that were created. */
ViewState["totalDynamicButtons"] = totalButtonToBeCreated;
}
/// <summary>
/// Creates a button and adds ot to the panel controls collection.
/// </summary>
/// <param name="i">The ordinal position of this button.</param>
private void CreateDynamicButton(int i)
{
Button btn = new Button();
btn.ID = CreateButtonUniqueId(i);
/* Attaches events */
btn.Click += new EventHandler(btn_Click);
btn.CommandArgument = "This is button no " + i.ToString();
btn.Command += new CommandEventHandler(btn_Command);
btn.Text = "Button no " + i.ToString();
/* Adds the button to its container "Controls* collection. */
panelButtons.Controls.Add(btn);
/* If we have specific information related to this button that we wish to access
* on each post-back we can add this information to the view state.
*
* ViewState["some_unique_key"] = some_unique_info;
*/
}
/// <summary>
/// This function creates a uniques id according to the passed integer.
/// </summary>
/// <param name="ordinal">The integer related to the dynamic button.</param>
/// <returns>A unique id for that button.</returns>
private string CreateButtonUniqueId(int ordinal)
{
return "dynamic_button_no_" + ordinal.ToString().Trim();
}
/// <summary>
/// Here we create dynamic buttons according to the number assigned to the text box.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void buttonCreateButtons_Click(object sender, EventArgs e)
{
int totalButtonToBeCreated;
if(int.TryParse(textBoxTotalButtons.Text, out totalButtonToBeCreated))
{
CreateDynamicButtons(totalButtonToBeCreated);
}
}
/// <summary>
/// Here is an implementation of the dynamic controls events.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
void btn_Command(object sender, CommandEventArgs e)
{
labelCommandMessage.Text = (string)e.CommandArgument;
}
/// <summary>
/// Handles the Click event of the dynaic buttons.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void btn_Click(object sender, EventArgs e)
{
/* Do what ever you want to. For example: */
Button btn = (Button)sender;
labelClickMessage.Text = btn.ID + " pressed!";
}
}
================
Have a nice day!
================
|
|
|
|
|
I have a gridview control and When i click on the headers to sort the column of the grid the dataset is getting refreshed. And when i move on to the next page the sort order is not maintained. So how do i stop the dataset from reloading when i moveon to the next page??
|
|
|
|
|
you just need to re-bind the datasource using the sorted data to your gridview control when headers are clicked.
|
|
|
|
|
Hi Nice People,
I have a table with a of rows of number links and another of Infragistic UltraWebTab control. How can I add html kind of anchor links in Infragistic UltraWebTab? Or how can I have my the starting links set in my first but have the anchor set in the Infragistic UltraWebTab in my another ?
Thanks much!
|
|
|
|
|
You might find more help for this on the infragistics newsgroups at their site.
|
|
|
|
|
I have a "Search" form with two buttons and a bunch of textboxes. The first button is a "Logout" button while the 2nd button is a "Search" button (I named it btnSearch).
If the user enters text into any textbox and then clicks enter, the logout button is accessed instead of the Search button meaning the only way to search is for the user to manually click the Search button.
I've tried using code such as "btnSearch.Focus();" & setting the defaultfocus property to "btnSearch" in my "form" tag, however neither has worked.
So how can I set my page so the user accesses the Search button when they click "Enter"?
Thanks in advance.
-Goalie35
|
|
|
|
|
Read my reply to the post below.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Hi,
I am Ravindra,presently doing a project in asp.net.
The Login page of my Web Project consists of two Buttons.
If user enters his username and password and clicks on enter button of keyboard,
the Signin button is to be submitted not the other button.
So,please specify how to get focus on the specified Button
Thanks in advance.
Ravindra
|
|
|
|
|
Javascript can be used.
With Regards
Satips
|
|
|
|
|
put the script below in your page.
function ButtonPress (evt, btnID)
{
if (evt.keyCode == "13")
{evt.returnValue= false ; evt.cancel= true ; document.getElementById(btnID).click(); return false; }
}
//the code behind should have
this.txtPassword.Attributes.Add("onKeyPress", @"ButtonPress(event, '" + @this.ButtonSignin.ClientID + @"')");
//this code will cause the button click event when the user presses enter and the textbox has the focus. Basically you can set a default button for each textbox
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Try using tabindex properties of the controls..
set tabindex to 1 for username
2 for password
3 for the button u want to click..
hope this will help u solve ur problem...
|
|
|
|
|
at page load event i used seesion variable to insalize lable control which is present on master page. it work perfectly on all web page who inherite master page accept one web page.
page laod, page preload, preinint, PreRender any of the above event not fired when i load my webpage. even they can't show message by
response.write();
please provide help.
deepak
|
|
|
|
|
You probably have AutoEventWireup set to false for that page.
Either change that to true or hook up your event handlers by hand.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Hi all,
I have a webservice method (call is method X) that is called from a windows forms client. This webservice method X instantiates a class in another assembly (call it assembly A) and calls one of its methods (Y). Assembly A has as reference a COM object written in C++.
In method Y, I instantiate a class from the COM object and call a method of that class (method Z.)
Then the result of Z is sent to Y, which returns it to X, which returns it to the client application.
Now everything works fine if I have only ONE client application calling method X of the webservice. As soon as I launch another call to X from another client application, I start getting exceptions being thrown from the COM. The COM itself uses many mathematics DLLs which I have placed in System32. I notice that the exception is generated from a particular method in one of those DLLs.
Is it right to assume that this particular DLL throwing the exception is not ThreadSafe?
When a second client application calls method X, don't we have a new thread being launched? and if so, then why does the COM seem to be behaving as if all instance of method Z are calling the same COM instance?
I'm quite lost at this one as I have no experience with COM stuff, could someone explain to me what is going on? and if there is a way to make more than one instance of the COM to run simultaneously.
Thanks a lot.
Talal.
Make it possible for programmers to write programs in English, and you will find that programmers can not write in English. - Murphy's Law
|
|
|
|
|
i have a datagrid say grid1 in one page say page1,ill bind only few columns in the grid1,ther s link label in grid1 on clicking that i open a page say page2 which also has a grid say grid2 and i select a pariticular row from grid2 on clicking the checkbox and the seleted row data shud be binded to the 1st grid,
my problem is agter i select the row from the 2nd grid and say ok,the 1st page refreshes and few clumns wat i had binded earlier gets erased
how do i solve this
Regards
Kavitha
|
|
|
|
|
HI
Guys,Can any one let me know how to make the web application DDA(disability discrimination act) compliant, so the disable persons(blind,deaf etc) could also access our web application with out any hinderance, plzzzz reply ASAP,thankx in advnace for ur help.
|
|
|
|
|
I have an open ip in my office we have hosted a site on that ip as master. when i type my ip the first page opens. I have used ajax in my site and register in web.config
there is also other sites when we try to access them they throws the error.
i takes roots web.config as thier own and searches for ajax file but not every project in ajax. non ajax project only throw error
Plzz help me to solve this problem
|
|
|
|
|
Hello Buddies
I want to get DSNs and Tables of corresponding database of DSN ,where browser is running. i.e when user opens browser ,all DSNs and their Tables of client Pc have to fill in dropdownlist box.Actually I am working Sending SMS in Bulk. we provide to import SMS data through ODBC.i requied all DSNs of Where browser(client PC) is opend. I have done through reading .INI file but it always reads Server DSNs
which is not what actually i wanted.
If anyone have some idea or sample code ,plz help me.
Thanks & Regards
Vinay Singh
Vinay@cube-software.com
"Every thing matters in this world but what you think,it matters more.
When thinking changes,the whole world changes."
|
|
|
|