|
I have an editable gridview with blank cells. User enters some numeric data in cells and also user can clicks a button to add new row to gridview. My problem is that, as soon as button click event is fired, the page refreshes & the gridview becomes empty. Can anybody tell me, how can I save values in gridview until the user saves all changes to the server in the end
|
|
|
|
|
Look at the section on Edit Mode, DataGridDemo[^]
Store the values entered in a datasource, such as a datatable that is bound to the grid. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
How is it possible to change the database which the login control is using based on the selection of the database name from a dropdown control?
Thanks
|
|
|
|
|
Create the ConnectionString dynamically based on the selection.
|
|
|
|
|
|
Hello,
I would like to have several settings inside the webconfig file.
i.e.
<LOB>x</LOB>
<LOB>y</LOB>
<LOB>z</LOB>
<LOB>A1</LOB>
then in C#, I would like to populate a dropdown list with these values i.e. x, y, z, A1
What is the first thing to do in the webconfig to place these settings?
Thanks
|
|
|
|
|
The first thing to do is read this, How to get answers to your question[^]
Then read a book. Even a basic ASP.NET book covers web.config file I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi,
Please note that I do know how to retrieve values from something like <appsetting> in the web config by referring to the key but I do not know how to retrieve values if there is no key for example:
<LOB></LOB>
<LOB></LOB>
<LOB></LOB>
Then how do I populate a dropdownlist with the values in these pls?
Thanks
|
|
|
|
|
You need to add a appSettings section in your web.config
i.e.
<appSettings>
<add key="variableName" value="someValue"/>
</appSettings>
Now to read that value.
string x = System.Configuration.ConfigurationSettings.AppSettings.Get("variableName");
Hope this helps, its up to you how to use this.
|
|
|
|
|
Hi, At present I do have these settings for other things. But the new requirement is to add something like the example I showed earlier.
So is it possible to add to the appsettings sections several lines with the same key? so that I can loop through that one key to get the values i.e.
<appsetting>
<add key="LOB" value="x"/>
<add key="LOB" value="y"/>
<add key="LOB" value="z"/>
...
Is it possible to just populate a dropdown list with the values of each LOB ?
Thanks
|
|
|
|
|
No, but you can separate the values by comma in the same key. and at the coding side you can read it accordingly.
i.e.
<add key="LOB" value="x,y,z"/>
and when you read the key split the string using comma.
i.e.
string []x = System.Configuration.ConfigurationSettings.AppSettings.Get("variableName").Split(",");
|
|
|
|
|
What I exactly would like to do is as follows:
On the main page of the site, there will be a dropdown with the names of the databases. On selecting a database name from the drop down list control, then the system will use one of the connectionstring settings which points to the relevant database.
so there are several connectionsettings i.e.
<....connectionstring...database=x..../>
<;....connectionstring...database=b..../>
...
I would like to make sure the correct connectionstring is used.
How can I do this please?
Thanks
|
|
|
|
|
Why save them in the web config? only config settings should be there.
How about a separate xml file. You then have total control over the format of the xml and can read it using the XMLDocument object.
|
|
|
|
|
I am interested in the connectionstrings as there will be several conectionstrings in the web.config i.e. one for each database.
The database is selected on the start page and then the correct connectionstring should be used.
What do you think now?
Thanks
|
|
|
|
|
The difference with connection strings is threefold.
Firstly the nodes are distinguised by their name attribute
Secondly they are, or can be secured. Connection strings can be encrypted, stored in the registry and so on
Thirdly, they are easily maintainable in the IIS managment console.
Web,Config is the right place for them.
|
|
|
|
|
|
Yes, I do at present have the appsettings for other settings...
In this appsetting each line has a key which allows me to refer to it in code.
For example let's say today I add a setting for a business i.e. <lob>Accounts then next week there will be a new business, so then I will add another line to the setting i.e. <lob>Audits and so forth. So you see, these lines get added to every time.
Somehow I need to retrieve these values and populate a dropdownlist with i.e.Accoounts, Audits, etc...
The question is how do I refer to these settings if there is no key?
Thanks
|
|
|
|
|
Have you even read the link that was given? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Good morning,
I've searched the web for a week to find a solution to a problem, but I can't figure it out, so now I'll try to post directly what the problem is and hope that someone could explain me how to go ahead. I'm new to Asp.Net, and some years have passed since I used to programme in C/C++.
I have an aspx page with two "Controller" textboxes.
If you insert a number X in TB1, on the OnTextChanged event, a Placeholder is populated with X TextBoxes (the number you entered).
If you insert a number H in TB2, on the OnTextChanged event, a Placeholder2 is populated with H TextBoxes (the number you entered).
The problem is that each time you enter a number you have a postback, hence after the first time, you loose all the data and the TextBox Controls in the PlaceHolder already populated. I cannot use Ajax UPdatePanel, so I know I should save the user data with the viewstate or Session, but i don't have idea of how to recall them to repopulate the PlaceHolder after Postback.
Here is my code C++C#(I tried to leave just the interesting parts).
<table>
<tr><td valign="middle"></td>
<td><asp:TextBox ID="cldtb" runat="server" OnTextChanged="cldtb_OnTextChanged" AutoPostBack="true"></asp:TextBox></td>
<td valign="middle"><asp:Panel id="pnlEnterNumbers" runat="server">
<asp:PlaceHolder id="myPlaceHolder" runat="server" /></asp:Panel> </td> </tr>
</table>
protected void cldtb_OnTextChanged(object sender, System.EventArgs e)
{
int I, intNumberCount;
intNumberCount = System.Convert.ToInt16(cldtb.Text);
if (intNumberCount > 0)
{
System.Web.UI.WebControls.TextBox txtNumber;
for (I = 1; I <= intNumberCount; I++)
{
txtNumber = new System.Web.UI.WebControls.TextBox();
txtNumber.ID = "birthdate" + I;
txtNumber.MaxLength = 8;
myPlaceHolder.Controls.Add(txtNumber);
}
ViewState["NumberCount"] = (I - 1);
}
}
modified on Monday, February 22, 2010 5:52 AM
|
|
|
|
|
smilingeyes76 wrote: Here is my code C++
This is C#, not C++. You don't even know what language you are using
smilingeyes76 wrote: (I tried to leave just the interesting parts).
Still way to much, but it does show that you have no idea what you are doing.
Why are you creating the controls dynamically in the first place?
smilingeyes76 wrote: I've searched the web for a week
Try searching for the proper way to create custom controls and supporting postback I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thank you Mark.
Yes, I made a mistake in writing, I know it is C#.
I need dynamic controls because their number depends on the value of a static control.
I solved my problem with javascript.
I'm studying tutorials, and I'm learning step by step while practicing, also thanks to experts like you, that explain newbies how to proceed...
|
|
|
|
|
Hi, I have hooked up a textbox to an autocomplete extender control and it seems to work fine with me restricting what is displayed as the user types via a web method in the code behind. I am using the CreateAutoCompleteItem key value pairs method. I have also created an OnClientItemSelected event which can update the value of a hidden field.
The problem I have is when the user might want to retrieve a record and I want the textbox to display the correct value when the page loads. If possible making my textbox have key value pairs, etc.
Can anybody please suggest a way?
Thanks
|
|
|
|
|
this is code i wrote to check check boxes in datalist control
but if i checked all checkboxes only it is returning true not for one or multiple checkboxes
help me...
foreach (DataListItem dli in DataList1.Items)
{
CheckBox Chk = (CheckBox)dli.FindControl("CheckBox1");
if (Chk.Checked)
{
str13 = "cheked";
}
else
{
str13 = "you need to check";
}
}
LblErr.Visible = true;
LblErr.Text = str13;
|
|
|
|
|
If you are talking about the value of LblErr.Text, it will always be according to the checked state of your last item in DataList1.
I am sure you can easily guess why is it so.
If you want your str13 to have "cheked" for one or multiple checkbox checked, just add a break statement just after the statement str13 = "cheked";
foreach (DataListItem dli in DataList1.Items)
{
CheckBox Chk = (CheckBox)dli.FindControl("CheckBox1");
if (Chk.Checked)
{
str13 = "cheked";
break;
}
else
{
str13 = "you need to check";
}
}
LblErr.Visible = true;
LblErr.Text = str13;
This should solve your problem.
|
|
|
|
|
thank you bro..
|
|
|
|