473,586 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Link Button not doing what I want it too

Hello All,

Basically What I did is create a gridview with 7 columns. One of the
columns is the LinkButton that binds it's text value to a column in my
dataset. The rest of the columns are pretty easy to see. The thing that
is not working is when I click on my linkbutton, I want to check
another column value of that row. Once I got the value, I will do two
different things based of the value. The two primary things I want to
do is either redirect the the user to another page or 'open a new
window'. I tried what ever I can think of and no luck...

Here is an example of my GridView and My
GridView_OnSele ctedIndexChange d Method. Any help would be greatfull.
The Value I want from the other column is Cell[7] of each row.

javascript:
<script type="text/javascript" language=javasc ript>

function OpenWindow(ul)
{
var docUrl = ul;
window.open(doc Url,

'', 'width=800,heig ht=600,resizabl e=yes,menu=yes' );
}
</script>

<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue"
DataKeyNames="D ocID" AllowSorting="T rue" AutoGenerateCol umns="False"
CellPadding="4" DataSourceID="G etDocs" Font-Names="Verdana"
Font-Size="8pt" ForeColor="#333 333" GridLines="None "
OnSelectedIndex Changed="GridVi ew1_SelectedInd exChanged" Width="100%"
OnDataBound="Gr idView1_DataBou nd">

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True" ForeColor="Whit e" />

<Columns>

<asp:TemplateFi eld ItemStyle-Width="16px">

<ItemTemplate>< asp:ImageButton ID="ImageButton 1" Width="16" Height="16"
ImageUrl="~/images/iconbar_deletet ab.gif" CommandName="De lete"
runat="server" OnClientClick=" return confirm('Are you sure you want to
delete this document?');" /></ItemTemplate>

</asp:TemplateFie ld>

<asp:ImageFie ld HeaderText="Typ e" SortExpression= "ContentTypeIma ge"
DataImageUrlFie ld="ContentType Image">

<ItemStyle HorizontalAlign ="Left" Width="3%" />

</asp:ImageField>

<asp:TemplateFi eld HeaderText="Nam e" SortExpression= "LeafName"
ItemStyle-ForeColor="#5D7 B9D">

<ItemTemplate >

<asp:LinkButt on ID="docLink" runat="server" Text='<%#
Bind("LeafName" )%>' CommandName="Se lect"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateFie ld>

<asp:BoundFie ld DataField="Type " HeaderText="Doc Type"
InsertVisible=" False" ReadOnly="True"

SortExpression= "Type" >

<ItemStyle CssClass="Invis ibleColumn" HorizontalAlign ="Center"
Width="1%" />

<HeaderStyle CssClass="Invis ibleColumn" />

</asp:BoundField>

<asp:BoundFie ld DataField="Crea tedDate" HeaderText="Mod ified"
SortExpression= "CreatedDat e" >

<ItemStyle HorizontalAlign ="Left" />

</asp:BoundField>

<asp:BoundFie ld DataField="Crea tedByUser" HeaderText="Mod ified By"
SortExpression= "CreatedByU ser" >

<ItemStyle HorizontalAlign ="Left" />

</asp:BoundField>

<asp:BoundFie ld DataField="Cont entSize" HeaderText="Con tent Size"
SortExpression= "ContentSiz e" >

<ItemStyle HorizontalAlign ="Left" />

</asp:BoundField>

<asp:BoundFie ld ItemStyle-CssClass="Invis ibleColumn"
HeaderStyle-CssClass="Invis ibleColumn" DataField="DocI D" />

</Columns>

<RowStyle BackColor="Whit e" ForeColor="#333 333" />

<EditRowStyle BackColor="#CCC CCC" />

<SelectedRowSty le BackColor="#FFF FFF" Font-Bold="True"
ForeColor="#5D7 B9D" />

<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />

<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True" HorizontalAlign =Left
ForeColor="Whit e" />

<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />

</asp:GridView>
Method:
protected void GridView1_Selec tedIndexChanged (object sender, EventArgs
e)
{
int _temp1,_temp3;

string _temp2;

LinkButton lb =
(LinkButton)Gri dView1.Selected Row.FindControl ("docLink");
_temp1 =

Convert.ToInt32 (GridView1.Sele ctedRow.Cells[3].Text);
_temp2 = lb.Text;

_temp3 =

Convert.ToInt32 (GridView1.Sele ctedDataKey.Val ue);

if (_temp1 == 1)
{

GotUrl(_temp1, _temp2, _temp3); (THIS WORKS FINE -WHICH REDIRECTS THE
USER)

}
else if(_temp1 == 0) ( NOT WORKING)
{
string ul = "DocumentViewer .aspx?DocID=" +
GridView1.Selec tedDataKey.Valu e.ToString();
body.Attributes .Add(

"onclick", "OpenWindow ('" + ul + "');");
}

}

Jul 14 '06 #1
0 1249

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4864
by: shank | last post by:
Is there any one "add to favorites" code that will work for IE, NS, AOL, and a host of others? At least some code that will give me an effective "add to favorites" for the highest percentage of users. The code in my searches have been disclaimed has working with this but not that. I'm not sure how old some of this code is either. thanks!
1
2801
by: Jonatan | last post by:
Hi all, I'm trying to upload files doing something like gmail. I almost got it but I have a problem when I post the form. Basicaly, I am doing the following. When the user presses the link I create a input type="file". Then I fire the click event of the control and the open file dialog appears. The user selects a file and then the...
2
3830
by: Mal P | last post by:
Hi there, I'm a J2EE fellow who (as usual) has been thrown in the deep end and have to learn a fair chunk of the .NET platform (VS, ADO, WebForms, C# etc) in roughly two days. I'm doing ok so far, but am wondering on a better way to do something... Basically, I have a form which has a few fields the user fills in. When submitted, the...
0
277
by: Normie Smith | last post by:
Hello... I have a strange situation happening, and I thought maybe I could get some assistance. I have created a simple user control (.ascx) file that's part of my default.aspx page. The user control contains a link button control, such as: <asp:LinkButton id="idLinkButtonopenAll" runat="server">open all</asp:LinkButton> Then in my...
4
4823
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the value of the "id" field of that record as a URL parameter. Can someone tell me how to do this.
5
15793
by: Sean M. Loftus | last post by:
I have a need to call an html page into the pane I'm viewing using a button on an ASP page. The page itself is an ASP page called from a website. I know a link would work but the rest of the page has buttons and it would look cleaner to use a button. I've tried the below in a few variations, including using a href tags inside the onclick....
2
10037
by: pradeep_TP | last post by:
Hello world, I have a simple datagrid on asp.net web form , in which I am showing a single button column called EDIT. The code in the .aspx files for the same is as below. <asp:ButtonColumn HeaderText="" ButtonType="LinkButton" Text="Edit" CommandName="EditRec">
2
1960
by: mcraven.2 | last post by:
How do you send a browser to a link when a command is given? I've tried using Java Server Pages <jsp:forward /command but that doesn't change the link in the address bar and some other problems arise with it. A javascript method would work in what I'm doing but I don't know what that command would be. Basically, when a button is pressed I...
5
2409
by: Matt | last post by:
Creating Dynamic aspnet link buttons with in user control, Then i use the control on ever page with wraped with master page. I get the url of the link buttons from xml. Parameter from xml also Builing Dynamicly link buttons with url's works fine. The problem is when i click the buttons they First link button and second link button works third...
7
5717
by: Steve Swift | last post by:
How close can you get to making a submit button look like a link? Answers to the inevitable questions: 1. Because I don't want my email address (which would have to be part of the URL in a real link) becoming obviously visible. 2. Because I'm limited for space and even a styled button takes too much room. --
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7841
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8204
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.