473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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_OnSelectedIndexChanged 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=javascript>

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

'', 'width=800,height=600,resizable=yes,menu=yes');
}
</script>

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
DataKeyNames="DocID" AllowSorting="True" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="GetDocs" Font-Names="Verdana"
Font-Size="8pt" ForeColor="#333333" GridLines="None"
OnSelectedIndexChanged="GridView1_SelectedIndexCha nged" Width="100%"
OnDataBound="GridView1_DataBound">

<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<Columns>

<asp:TemplateField ItemStyle-Width="16px">

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

</asp:TemplateField>

<asp:ImageField HeaderText="Type" SortExpression="ContentTypeImage"
DataImageUrlField="ContentTypeImage">

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

</asp:ImageField>

<asp:TemplateField HeaderText="Name" SortExpression="LeafName"
ItemStyle-ForeColor="#5D7B9D">

<ItemTemplate>

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

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="Type" HeaderText="DocType"
InsertVisible="False" ReadOnly="True"

SortExpression="Type" >

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

<HeaderStyle CssClass="InvisibleColumn" />

</asp:BoundField>

<asp:BoundField DataField="CreatedDate" HeaderText="Modified"
SortExpression="CreatedDate" >

<ItemStyle HorizontalAlign="Left" />

</asp:BoundField>

<asp:BoundField DataField="CreatedByUser" HeaderText="Modified By"
SortExpression="CreatedByUser" >

<ItemStyle HorizontalAlign="Left" />

</asp:BoundField>

<asp:BoundField DataField="ContentSize" HeaderText="Content Size"
SortExpression="ContentSize" >

<ItemStyle HorizontalAlign="Left" />

</asp:BoundField>

<asp:BoundField ItemStyle-CssClass="InvisibleColumn"
HeaderStyle-CssClass="InvisibleColumn" DataField="DocID" />

</Columns>

<RowStyle BackColor="White" ForeColor="#333333" />

<EditRowStyle BackColor="#CCCCCC" />

<SelectedRowStyle BackColor="#FFFFFF" Font-Bold="True"
ForeColor="#5D7B9D" />

<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />

<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" HorizontalAlign=Left
ForeColor="White" />

<AlternatingRowStyle BackColor="White" ForeColor="#284775" />

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

string _temp2;

LinkButton lb =
(LinkButton)GridView1.SelectedRow.FindControl("doc Link");
_temp1 =

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

_temp3 =

Convert.ToInt32(GridView1.SelectedDataKey.Value);

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.SelectedDataKey.Value.ToString();
body.Attributes.Add(

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

}

Jul 14 '06 #1
0 1242

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

Similar topics

9
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...
1
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...
2
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...
0
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...
4
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...
5
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...
2
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. ...
2
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...
5
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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,...

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.