|
Hi
How can I select and hyperlink the contents of a row in a gridview server control dynamically.I want the contents of the selected row to be transferred to the next page(using the hyerlink).
ANy onwe who can help me?
thanks
kidus
|
|
|
|
|
What do you mean, dynamically? At runtime on the client-side? Right some javascript to handle the mouseover event on the row.
Server-side? Use a template.
only two letters away from being an asset
|
|
|
|
|
hi
I mean at ruutime and on the server side.I wrote using mouseover on the client side but it doesn't hyperlink?
Can y show me on both?server side and client side scripting?
thanks
kidus
|
|
|
|
|
Server-side is easy, like I said you need to use a template. See the template columns section in this article.
http://www.codeproject.com/aspnet/datagriddemo.asp[^]
If you create a hyperlink using the above method there is no need to use client-side scripting.
kidus1 wrote: I wrote using mouseover on the client side but it doesn't hyperlink?
Explain what your tried. So some code.
only two letters away from being an asset
|
|
|
|
|
hi
I created a clickable gridview control but I can't hyperlink to other page.I am trying to do this using Javascripts.
Any help?
thanks
kidus
|
|
|
|
|
kidus12 wrote: Any help?
Show the code you are using, then maybe we can help. I don't understand how are you creating this "clickable gridview" in javascript?
only two letters away from being an asset
|
|
|
|
|
hi
here is the code for creating the clickable Row using Javascript
if (e.Row.DataItemIndex == -1)
return;
e.Row.Attributes.Add("onMouseOver",
"this.style.cursor='hand';");
e.Row.Attributes["onmouseover"] =
"javascript:setMouseOverColor(this);";
e.Row.Attributes["onmouseout"] =
"javascript:setMouseOutColor(this);";
e.Row.Attributes.Add("onclick",
this.GetPostBackClientEvent(GrdDynamic,
"Select$" + e.Row.RowIndex.ToString()));
and what I want to do is to hyperlink to other page when the row in the clickable gridview is clicked and passed the contents of the clicked row to the other page(using session).
thanks
kidus
|
|
|
|
|
You are trying to make it more difficult than it is. Use a template column or Hyperlink column to create the link, pass the id of the row to the next page and retrieve the row data from the datasource on that page.
only two letters away from being an asset
|
|
|
|
|
hi
pls ..... some small example
thanks
kidus
|
|
|
|
|
I already have. Figure it out. It isn't that difficult.
only two letters away from being an asset
|
|
|
|
|
Hi
You can Create a HyperLinkField column(s) for GridView.
Cheers
Chandu
|
|
|
|
|
I think I am missing something small, and I can't figure it out. Can anyone help? I am looping through a gridview pulling out a data field and putting it into an arraylist. Then putting that array list later into a string var. My code is as follows:
Dim emailaddresses = New ArrayList
Dim Key
For Each gvr As GridViewRow In GridView1.Rows
Key = GridView1.DataKeys(0)
emailaddresses.Add(Key.value.ToString())
Next gvr
'Trim Size
emailaddresses.TrimToSize()
Dim strMain As String ' Will be used to populate email address in message
Dim iList As Integer ' Var to count through the array
Dim iCount As Integer ' Count of recs in array
iList = 0 ' set iList to 0
'strMain = ""
iCount = emailaddresses.Count() ' get size of array
Do Until iList = iCount
'Populate string with array record
strMain = strMain & emailaddresses.Item(iList) & ","
emailaddresses.Remove(iList)
'Count up 1
iList = iList + 1
Loop
My problem that I am having is no matter how many records are in the array the first record populates all of the array. So if my grid has 5 unique values, it will display 5 items, but all are the first record from the gridview, not 5 different items. I think this has something to do with the way I am looping through the gridview. This is ASP.NET 2.0.
THANKS!
BJJONESEY
|
|
|
|
|
bjjonesey wrote: Do Until iList = iCount
'Populate string with array record
strMain = strMain & emailaddresses.Item(iList) & ","
emailaddresses.Remove(iList)
'Count up 1
iList = iList + 1
Loop
Reverse the looping,
iList = iCount - 1<br />
Do Until iList < 0<br />
'Populate string with array record<br />
strMain = strMain & emailaddresses.Item(iList) & ","<br />
emailaddresses.Remove(iList)<br />
'Count up 1<br />
iList = iList - 1<br />
Loop
|
|
|
|
|
Thanks for the response. That works!
Ben Jones
|
|
|
|
|
I need to iterate through the rows in a datagrid and record the number of rows that are checked (checkboxes in a templatecolumn). I need to do that on the client side. The object of this is to either submit if none of the checkboxes are checked or prompt the user to save records (via javascript confirm). The code-
function dtgValidateCheckBox(grdid, objlist)
{
//if user clicks on "Search", then this method
//will check to see if there are products
//selected but not saved. User is prompted
//to either continue and loose items in the cart
//or cancel and then click on save items to cart.
//attribute is added from the server side to fire this method.
var chkbox;
var i=20;
var iCount=0;
chkbox=document.getElementById(grdid + "__ctl" + i + "_" + objlist);
while(chkbox!=null){
if(chkbox.checked == true)
{
iCount++;
}
i=i+1;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objlist);
}
if(iCount>0)
{
return confirm("There are unsaved items in your cart. Do you wish to continue?");
}
}
Any Ideas?
|
|
|
|
|
hi wood0601
just try to send count of rows in grid and pass the value to javascript. I hope it will easy to u.
k.ravi sankar
|
|
|
|
|
Thanks priyaram1. Not sure how. Do you have any example code?
|
|
|
|
|
This sample script for validating the textboxes in datagrid.
function quanvalid(k)
{
var a = new Array(k);
var count =2;
var sam;
var falge=0;
for(var i=0;i<k;i++)
{
="" if(count="" <="" 10)
="" count="0" +count;
="" }
="" a[i]="CtrlPOUpdateControl1_POGrid_ctl" +count+'_txtqtynow';
="" sam="document.getElementById(a[i]).value;
" if(sam="" !="0)
" return="" true;
="" count++;
="" alert("should="" enter="" quantity");
="" false;
="" }
=""
<div="" class="ForumSig">k.ravi sankar
|
|
|
|
|
priyaram1. Thanks for the info. Your example gave me what I needed!
|
|
|
|
|
Is it a wise idea to use master page in a website. The name mangling problem in master page will affect the JavaScript and CSS style. The designer’s logics will sometimes breaks when the web developer applies master pages.
My question is :
1. how to solve name mangling problem
2. Keeping the JavaScript code as separate .js file (better solution for traffic and maintains)
3. Advantages and disadvantages in using master pages
4. performance
Does every one prefer using master pages? After reading several articles I am still confused on using master pages. Advice me...
|
|
|
|
|
You can replace the control's name in the page load event like this:
abstract string script = "[Label1ID].innerHTML = 'Hello!';";
abstract string scriptKey = "SayHello";
abstract bool addScriptTags = true;
protected void Page_Load(object sender, EventArgs e)
{
script = script.Replace("[Label1ID]", Label1.ClientID);
ClientScript.RegisterStartupScript(this.GetType(), scriptKey, script, addScriptTags);
}
|
|
|
|
|
1) What do you mean? How does it affect CSS and JavaScript?
2) Why can't you?
3) Advantages: Conformity throughout the application.
4) Not an issue
only two letters away from being an asset
|
|
|
|
|
Hi,
1. if we add a text box named as "TextBox1" inside a content page "ContentPlaceHolder1". Then asp.net generate the name "ctl00_ContentPlaceHolder1_TextBox1" on run time. This name mangiling problem will affect the javascripts that written by using the 'TextBox1'. the CSS that applies to a particual named tag (#topImage) will also get effected.
2. if name mangiling happens how can use the below script inside a .js file
var textbox1 = document.getElementById('TextBox1');
3. yes i agree with that. How to seperate programmer and designer logics.
4. i agree with that
|
|
|
|
|
The name mangaling is not a cause of using a master page. Using any container will cause this so as to uniquely identify the control on the page. You just have to understand this process and code accordingly. I have never had a problem with this, in javascript or with dynamic CSS.
only two letters away from being an asset
|
|
|
|
|
I have a details view that a user is editing a txt box called txtComments. When they hit update it is writing those comments to a db. I also want to write those comments to an audit table. So during DetailsView1_ItemUpdating I am having it write to another table. How can I get the contents of txtComments into my db? Is there a dtv.field command or something I can call?
-- modified at 12:04 Wednesday 13th June, 2007
Never mind I figured it out. For others to pull items out of the Details view, set another field as a data key and the following syntax will drop it to a variable:
DetailsView1.DataKey(1)
Where (1) is the key id of the field you are trying to pull. Remember you start off with 0!
BJJONESEY
|
|
|
|