Web Forms :: Passing Multiple Control Value And Field Together?
Nov 26, 2010
i have 2 dropdownlist and a gridview in product.aspx page, how to pass the value for dropdownlist 1 and 2, together with ProductCode parameter to another page?
I'm designing a sort of hierarchical system, as follows:
Contract Master Commodity Commodity Sub-Commodity Part
Each one of these are on their own page (for now). The user starts out on the Contract.aspx page. If they want to see the Master Commodities for the contract they are currently on, they will click the "ImageButton" I have set up, and I pass in as a command argument the ContractID (CommandArgument='<%# Eval("ContractID")%>'). This works great- I get to my Master Commodity page with the Master Commodities filtered on the ContractID I passed in.
Here's my problem: Navigating from the Master Commodity page to the Commodity page will (I think) require passing in the ContractID (so we JUST see stuff for the contract we're on), AND the Master Commodity ID (so we JUST see the Commodities that are related to the Master Commodity). I've tried the following: CommandArgument='<%# Eval("ContractID") + ',' + Eval("MComID")%>', but as you could probably expect, that doesn't work. If I can just do something like above and have a delimiter like the comma, I can go from there and make it work.
I have a doubt regarding displaying data in gridview. I have comma separated values in a particular field in my database. Will I be able to display the comma separated values from db table in a control in the Item template field of my gridview?
Below is the jquery script that takes one input value from textBox1 and pass it to a web method then returns the name of the person and displays it in textBox2. The web method only takes one parameter, the user initials.
[code]....
I want to be able to pass two values from two textboxes for a web method that requires two parameters. how can I modify the jquery code above to accomplish that?
I am able to transer the single value to another page(Pop_up) using following code i wanted to pass one more value to another page how can i add to following code.
I want to return all rows from a SQL Server 2008 database table into a SQL data source if a textBox field is blank. So I made a stored procedure with an if @date IS NULL clause.
Although the stored procedure seems to be working fine in Visual Studio 2008 the actual webpage displays no results.
I am guessing I have to send a DBNull value to the stored proc if textBox.Text == string.Empty. I tried the SqlDataSource1.SelectParameters.Add but it seems that I get a conversion error from DBNull.Value to string.
Is this the source of my problems or am I missing something else? How would I pass DBNull.Value to a stored proc if a textfield is blank?
I have added a gridview in my aspx web page. I have added a hyperlink field, to navigate to another page from the gridview. I am getting the error as:
"There was an error rendering the control.
Index(zero based) must be greater than or equal to zero and less than the size of the argument list. "
This is the code i have used:
[Code]....
[Code]....
When i remove the hyperlink, the grid is getting displayed. I know, there is something wrong i have coded in the DataNavigateURLformatstring, but not sure what is wrong.
I want to pass the StudentID,CourseID,ChildImageID with the link as the querystring.
Unfortunately, when the new webpage opens, the url contains lots of spaces and I'm struggling to remove all of the spaces. The code actually works but looks a bit messy, see below.
According to all I have read my DataNavagateUrlFields string should work but it isn't. The deal is that any one (AssocID) can have multiple AddrID's associated with it. Regardless of which I choose I only get back the first AddrID for that AssocId.
I am having a grid with the three column date, and mode.The last column is Edit.
When i click the edit button, i need to get the corresponding date and mode and show in the pop up. for that it is possible to pass two value in the command ergument.?
In ASP.NET WebForms I want to pass arbitrary data from server to client and back again. I am serializing to JSON and have been simply producing JavaScript that creates the object on the client. I have no problem sending data to the server with ajax, but there are situations where I also want to send a Javascript object data back to the server on postbacks. So I guess it needs to be in a hidden field.
1) What is the best way to do this in terms of minimizing complexity and optimizing space and efficiency? In researching this I discovered Protocol Buffers but there does not seem to be a good C# implementation. I did find one, but it was a couple years old and self-described as buggy so that scared me.
2) If I just pass a JSON string, how can I be sure it will be safe to include as the value for a hidden field? Is there any reason I might not want to do this? I could Base64 encode, but it seems like this adds a lot of overhead. What is considered the best or preferred method?
I have 2 columns (name and address) in a gridview which are defined as linked buttons. Now when i click on a record in the first row (name) i am able to pass that value (selected name) to another page with rowcommand. Now i am trying to click on the second row (address) on a record but am not able to pass that value to the second page. Don't actually know how to define this in the code below. The first row (name) has to redirect to one page (this what i have already accomplished) and the second row (address) has to redirect to another page
<asp:TemplateField HeaderText="Name"> <ItemTemplate> <asp:LinkButton ID="LnkBtnName" runat="server" CommandArgument='<%# Container.DataItem("Name") %>' Text='<%# Eval("Name") %>' CommandName="go" >LinkButton</asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Address"> <ItemTemplate> <asp:LinkButton ID="LnkBtnAddress" runat="server" CommandArgument='<%# Container.DataItem("Address") %>' Text='<%# Eval("Address") %>' CommandName="go" >LinkButton</asp:LinkButton> </ItemTemplate> </asp:TemplateField> Protected Sub GridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView.RowCommand Dim strName As String = CType(e.CommandArgument, String) Response.Redirect(String.Format("Test.aspx?id={0}", strName, False)) End Sub
CODE ON PAGE II:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load LblName.Text = Request.QueryString("id") End Sub
I would like to use the gridview paging feature and have built a gridview with a user control. The data source has lots of columns, so to make it easier I want to return a LIST<MyObject> and just pass <Myobject> into the user control rather than all the data elements. Not sure how I access the object of the data source to bind to the control. Assume it would be during ondatarowbound.
Also, my guess is there is a better way to do this than gridview. I'd take either solution that allows me to have easy paging and pass the complete object into the user control
I have req where i have to pass null value,if value coming from db is null.Problem here is the field datatype is 'Decimal' so all the time even though value is null ,its passing as zero.How can I pass a null value to decimal field in C#.
I am trying to pass data from client to server using a hidden field. If I use a button, then OnClientClick sets the value, and OnClick does the postback and all is well.
However, I am responding to a Client event, and although this works I get no postback. How do I now force a postback from my client handler?
While develop some asp site i have problem with multiple validations on one field. I have input box and 3 validations for it.
- Required Field - Compare Validation - Regular Expression
how to set validations priority. Ex. If Required Field catch error, then Compare Validation and Regular Expression validation messages to be hidden. If Compare validation catch error (and Required field is ok- entered something) then validation message for Regular Expression to be hidden... etc etc...
first of all, sorry if my title isn confusing as i dont really sure the specify description regarding what i wan to do. Now what i trying to do is, I getting 5 random images from the database, this is the code for me to get random 5 records from database:
[Code]....
I dont really know how to use array but willing to try if it is needed.
[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string MyWebMethod(string foo, string bar) { // DataContractJsonSerializer to deserialize foo and bar to // their respective FooClass and BarClass objects. return "{"Message":"Everything is a-ok!"}"; } I'll call it from the client via: var myParams = { "foo":{"name":"Bob Smith", "age":50},"bar":{"color":"blue","size":"large","quantity":2} }; $.ajax({ type: 'POST', url: 'https://mydomain.com/WebServices/TestSvc.asmx/MyWebMethod', data: JSON.stringify(myParams), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (response, status) { alert('Yay!'); }, error: function (xhr, err) { alert('Boo-urns!'); } }); However, this yields the following error (a breakpoint on the first line in MyWebMethod() is never hit): {"Message":"No parameterless constructor defined for type of u0027System.Stringu0027.","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) at System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2 rawParams) at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.MissingMethodException"}
I'd like to pass in two string parameters and use DataContractJsonSerializer to write new Foo and Bar objects. Am I missing something?