Please help me out here I have about 1 day experience of C# ASP.NET web dev and I am stuck on something really simple. I am much more experienced in PHP and jQuery.
What I need to do:
Create a GridView and display data from MSSQL DB [done]
Add buttons to each row to enable direct editing of values in two columns [done]
Each row represents a list of equipment that the user can edit/save, and I need to add an extra "Edit Details" button to each row [done]
Upon clicking the "Edit Details" button, I need to pass the id of that list to a new page where user can edit and save the list
I have added a HyperLinkField for the row id to be passed on, in Visual Studio I have tried to config it so that the value can be read on the receiving page with Request.Params["xxxx"] but it is not working.
In PHP I would just create a POST <form> with hidden <input> values and obtain the value by $_POST["xxxx"]
However it seems that all this fancy ASP.NET and Visual Studio DataSource pointer/reference and config things are making things more complicated than I wished.
I greatly appreciate any help given, or any resources that will be helpful for me to transfer my skills in PHP over to ASP.NET with C#.
If you are passing it through query string use
string value = Request.QueryString["id"].ToString();;
If you are passing it through post use
string value = Request.Forms["id"].ToString();
Related
I want to build a web page using asp c# which has 4 Cells Labeled "MachineName (Label), Owner (Dropdownlist), Release(dropdownlist with default values of Yes/No), Comments (Textbox)".
Content of the table is loaded from SQLServerDB.
1. In each cell it shows records for one Machine.
2. Owner is dropdownlist, which consist names list from SQLTable (ADuser) of 500 users. But by default it show the current owner of this machine fetched from SQLServer Table (inventory) from which we are getting machine names.
3. Release is simple dropdownlist with default values "Yes/No".
4. Comments is just Textbox.
5. Update/Submit button to update the record column.
I am trying to put all these in simple line. Machine name is static which cannot be edited, Dropdown, Release and comments should be editable and finally with Submit/link button at the end of the Columns to update the particular record only.
I tried by creating Grid, but in grid we get DELETE/EDIT/UPDATE button options.
Tried by creating Placeholder and generating and filling data using htmlappend option. But this way, i am not able to add/bind dropdownlist dynamically.
Any help is appreciated.
Hi everybody Sorry maybe this questions asked many times but most of the answers not fit with me,Perhaps the lack of my understanding of what was write in these forums.
I am new in C# I want to retrieve Id in dropdown another control from SQL Database and when a user click an id and click the button which is create PDF then all the data from table show in column in pdf.table name is profile
table attributes are name,fathername,picture,gender,status,age etc
Populating IDs in dropdown is easy. You can do that by choosing datasource.
For creating pdf, in the buttonclick event you can either use the inbuilt report viewer or any third party tools like ITextSharp.
You can read the selected id from dropdownlist as ddl.SelectedItem/ddl.SelectedValue
I m a newbie to C# and Ive got this doubt please help.
I have these 2 webpages lets call them pageA and pageB .PageA has got a table(used DataGrid) displaying all the fields of a table in sql server ,it has got an additional edit column which displays a link to PageB, the url for pageB has got a query string which contains the ID of the product that is to be updated .In PageB i have got an update form. The form fields of which is already filled (i.e im retrieving data using the ID from the query string using "select").This pageB has got a button which is supposed to update the fields that were edited in this page and store them back to the server .
In pageB :the Page_Load() is where i save the ID to a variable (VarID) and i call the method fill_data_fields() which does the "select" and fills the fields .I ve also got the update_click() which is called when i click the button on pageB it is in this method I ve written the code to update the fields in database .
The PROBLEM is ,that the method update_click() is never called when i click the button.
Any chance that you're adding the button programmatically rather than defining it in the asmx markup? ASP.Net is horrible with dealing with that issue. Also make sure you've wired your update_Click() button correctly in the asmx markup as well. Remember, C# is case sensitive!
This will not be a very clear explanation of my problem, but I don't know how to explain it better.
I have a gridview which I create dynamically on PreInit. This gridview has textboxes dynamically added on each row.
Everytime I push the button, I loop inside the gridview cells and get the Text of the textboxes -and update the database.
the first time the gridview is created, row uniqueID's are like this:
ctl03, ctl04, ctl05, ctl06 (thus, the textbox ID's are ctl03$txt0 etc..)
The first time I push the button, the row UniqueID's are still the same, so that I can find the controls by FindControl(ID) method, or using Request.Form[txt.UniqueID]
However; after the first time, whenever I push the button, the row ClientId's are created like the following: ctl02, ctl03, ctl04, ctl05.. So that I cannot find the Textboxes and cannot catch the Text written on them.
When I look at the rendered HTML code, I see that the rowClientID's are still the same with the first created ones (ctl03, ctl04, ctl05, ctl06)
Does anyone have any idea why the rowIDs (naming container IDs) change after the first update?
Thanks in advance.
One solution is to create your textboxes with static ids and not let it dynamic create by asp.net. This can be done if you use asp.net ver 4.
Other solution is to just render a simple <input name="KnowName01" id="KnowId01" type="text" value="your value here" maxlength="100" etc... >
and then on post back you just capture the return with the old way and get the value.
Request.Form["KnowName01"]
At the end, the TextBox is nothing more than a render of the input, plus some checks for what write on it, including Anti-XSS safe.
I have two dropdownlist on my webpage i want to fill both of that dropdownlist with a single code written in a separate class file. i want to pass the table name with field name and want to get that data into my used dropdownlist.
my code is as follows
ddl1 = obj.Method("table_Name");
now the following function return the dropdownlist
public dropdownlist Method(string table_NAME)
{
// code
return dropdownlist_1;
}
now i want to use this code for filling multiple dropdownlist, by using this i can reduce my code. same code will be use to fill other dropdownlists also.
Please help me as soon as possible.............
Thanks in advance.
Please view if ObjectDataProvider is the class you are looking for. Here is the reference:
http://msdn.microsoft.com/en-us/library/system.windows.data.objectdataprovider.aspx
You would need a server side scripting language (such as PHP, Perl, JSP, ASP, Python, and many more). Once you have a language selected, the code for that should be relatively easy. The basic algorithm would be:
Issue an database request to get the data to fill in
Iterate over your results and generate a form option from each one
Concatenate the form options to one another
Insert the resulting menu into your page