Home › Forums › Guriddo jqGrid JS › Help › Please help me with paramters passing to asp.net for id
A jqgrid uses below js script as sample and default.aspx page which display the grid using C# code. js Script:
|
1 |
<div class=""sfcode"">jQuery(document).ready(function(){ <br />jQuery("#htmlTable5").jqGrid({ url:'Default2.aspx?cmd=select', mtype: 'GET',<br /></div> |
Hello,
It is difficult to me to read your post.
Can you please write it a gain?
Just the description – I see the code.
Kind Regards
Thank you Tony for the msg. Here I rewrite what the issue is: When I click to select a row on the jqgrid it does
not send the selected row id field. In other word, for some reason that I cannot retrieve the id on the backend
C# code of the page that displays the grid.
Using Resquest.QueryString[“id”] / Resquest.QueryString[“que”] per my posted code above is always null, tried
to use post/get methods and still I cannot retrieve the id of selected row, even though I could see the grid
respond to my selection by showing the selected row id on the Caption of the grid, in addition that I could
trace using firebug utility that a response with parameters showing
que=1 and id=x.
Some info about the grid: the grid uses above JS code on the header of Default.aspx page
and Resquest.QueryString[“id”] / Resquest.QueryString[“que”] is used in the Page_Load section code of
same page (Default.aspx.cs).
I do not know why cmd=select would work to display the grid content but nothing else of other parameters,
how to pass a parameter
from the grid then to the page to be used like showing a picture of the selected row on the grid??
Is there a filter on the grid??? Is it suppose to be editurl to direct the response to a different page???
But why select parameter would work?? I'm really confused and tired of this issue. I appreciate any
hint or guide.
By the way why when posting on this forum the text are cliped from the most right side?
Hello,
Sorry, but I can not tell you why is this.
I'm not familiar with ASP C#and etc.
For me the there are some unsual thing.
1. When the row is selected you set new url and reload the grid. This will happen every time a row is selected.
Why do you not use this url by default.
2. You can use only one url and use postData to send a parameters to the server.
jqGrid('setGridParam', { postData: { id:id, …}});
The simple test case for me is
in a onSelectRow event do not use any grid code – just pur ajax and try to obtain the id like this
onSelectRow : function (id) {
tony Hello,
Following your suggestion:
onSelectRow: function (id) {
//var treedata = $("#htmlTable5").jqGrid('getRowData', id);
var selr = jQuery('#htmlTable5').jqGrid('getGridParam', 'selrow');
//var value = $('#htmlTable5').jqGrid('getCell', sel_id, '_id');
//alert('Selected row ID ' + id);
id = selr;
$("#htmlTable5").jqGrid('setGridParam', {postData: {id:id}, mtype: 'POST'});
$.ajax({
url: 'GetData.aspx?cmd=select&que=1&search=false&rows=10&page=1&sidx=id&sord=asc&id=' + id,
success : function(response) {
Hi,
Is your javascript doing a post back when you select a field on the jqgrid? So the link will be something similar:
localhost:port/Default.aspx?cmd=select&que=0&id=123
Where 123 is the ID selected in the jqgrid.
If that link is displaying and working correctly then you can use querystring on your pageload:
if(!IsPostBack)
12seconds said:
Hi,
Is your javascript doing a post back when you select a field on the jqgrid? So the link will be something similar:
localhost:port/Default.aspx?cmd=select&que=0&id=123Where 123 is the ID selected in the jqgrid.
If you talk about the url address on the webpage of the browser on top. No. It shows only the
name of the page “like localhost/website/Default5.aspx”, I feel that JqGrid does not refresh
entire page, I have setup Firbug (A utility shows what actually posted by the script to the
page) When I first load the grid I get on the param section the following:
http://localhost/webpage/Default5.aspx?cmd=select&que=1&_search=false&nd=
1379651648678&rows=10&page=1&sidx=id&sord=asc' (This does not show on the
browser URL as I stated)
and paramtered shown that suppose to be posted:
_search false
cmd select
nd 1379651648678
page 1
que 1
rows 10
sidx id
sord asc
While if I click on a field on the grid data (Say row with id 17) I get the following paramters shown:
cmd select
id 17
page 1
que 1
rows 10
search false
sidx id
sord asc
If that link is displaying and working correctly then you can use querystring on your pageload:
if(!IsPostBack)
Hi,
Yes, at all cases on the link only show “localhost/website/Default5.aspx” and I do not know how
the paramters for the grid are passed and retrieved by Response.QueryString like select, row, sord, sidx
of what the jqgrid needs to make response back of Json data format for the grid while adding id
and que parameters are not detected.
Hi,
Right, Reponse.Write cannot be used since no postback is done…
Since jqgrid doesn't postback to the server.. One option is to use ajax with code handler, or web service.
As for the javascript,
Whenever onSelectRow is called in jqgrid you assigned the ID to the hiddenfield. You don't have to use HiddenField, if you dont know about them you can just use a label and hide it.
However, if you do want to learn more about HiddenField, I suggest you to have a look into MSDN Library.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield.aspx
Please can you give me more details, I'm a novice in web techs, is it like what Tony said on his first post for ajax:
onSelectRow : function (id) {
Spent 20 mins on this so… Ill keep it simple.
I am using ajax with handler approach rather than using ajax and webservice which you can do to achieve the same result.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top