|
While you are looping items on GridView make unselect for each row except selected row.
Or put your code here to see what you did so far.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
My English is little. Please understand.
I was used delphi since five year ago.
But my new company want web page used ASP.net.
I want to put link text on picture.
If use link text on picture, Must I use java script?
Please let me know example or method.
I am waiting your reply.
Thanks you
|
|
|
|
|
You can use LinkButton control in asp.net. Have a look here
Another example : Using LinkButton Server Controls
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Thanks for your reply
Regarding the link button, I knew to use its.
Can it put on picture?
I can't put link button on picture(Image).
|
|
|
|
|
Will ImageButton Control resolve your issue?
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Thanks for your cooperation.
I want to use link text on picture.
example)
Please see main menu bar in this web page.
Link text(home, Articles....help!) is on green image.
|
|
|
|
|
The image will be the link.
If you are trying to place a hyperlink over top an image? If so then you need to use CSS to position the elements.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am making board by using gridview.
Until now, i made similar board but i want to other fuction which not only page navigator also FIRST, LAST, Prev, Next page navigator. and button bottom of gridview.
Is it possible?
I want to attach picture but i don't know how can i upload file.
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
|
Mark Nischalke wrote: A picture may be worth a thousand words ...
wouldn't it be nice if MSDN pages, like the ones you linked to, would show us some pictures so we can see what we could get from those classes, methods, and properties? I never understood why they are so reluctant to use some more graphics and images...
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
How can I access a method on a child page from its master page ?
I have a Datagrid on my masterpage. Is acts as filter for the content and it´s pages below.
As I have the Selection Event after the PageLoad Event (Master and Child), I wana call the Content Page Comand directly from the masterpage event.
Thanks.
Guilherme
|
|
|
|
|
You can't really call a content page from the master page. The master page doesn't know what page is using it, that's the point. You can, however, create an event on the master page and have a content page subscribe to it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
The Page property gives access to the content page.
|
|
|
|
|
True enough but the page object would need to be cast to an object that had the method needed, either as a concrete class or interface. The master page would need to know too much in my view.
It would also limit the ability to change the master page if required. I like the flexibility of subscribing to an event.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: It would also limit the ability to change the master page if required
Not if you put one method per interface.
|
|
|
|
|
So adding more and more interfaces and implementations when more functionality is needed? Rube Goldberg would be proud.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Events do have at least one distinct advantage. They are a public part of the class, which makes it more obvious that the functionality is available.
|
|
|
|
|
I will assume you are using C#. Use this.Page .
First, you will create an interface that defines the methods you want to call (I put this code in INamedObject.cs):
namespace WebApplication70
{
public interface INamedObject
{
string GetName();
}
}
Then, your Primary.Master will access this.Page and cast it as an INamedObject to call GetName() :
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Primary.master.cs" Inherits="WebApplication70.Primary" %>
<%@ Import Namespace="WebApplication70" %>
<html>
<head runat="server">
<title>Master/Page Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1><asp:Label runat="server" ID="lblPageName" /></h1>
<asp:ContentPlaceHolder ID="body" runat="server" />
</div>
</form>
</body>
</html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string pageName;
if (this.Page is INamedObject)
{
pageName = (this.Page as INamedObject).GetName();
}
else
{
pageName = "Unknown Page";
}
lblPageName.Text = pageName;
}
</script>
Create a page, Default.aspx, that makes use of the masterpage:
<%@ Page Language="C#" MasterPageFile="~/Primary.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication70.Default" %>
<asp:Content ContentPlaceHolderID="body" runat="server">
<p>This is the default page.</p>
</asp:Content>
In the code behind (Default.aspx.cs), you will implement the interface:
namespace WebApplication70
{
public partial class Default : System.Web.UI.Page, INamedObject
{
public string GetName()
{
return "Default.aspx";
}
}
}
|
|
|
|
|
I'd avoid doing this though, as far as possible. By implementing in this way you increase the coupling between the master page and this particular page. If this pattern were to be repeated it would result in a maintenance nightmare.
Depending on the reason the OP wants to pass information up to the MasterPage, there are normally other mechanisms.
|
|
|
|
|
Often times, the purpose of the masterpage is to reuse content, and coupling isn't a factor. Besides, my example isn't tightly coupled... it makes use of an interface, which allows any page to implement the desired behavior (or not).
Still, an event driven technique (observer pattern) may be cleaner, though I'm not sure because I can't tell exactly what the OP wants to do.
|
|
|
|
|
Oh I know what a MasterPage is for, and what you suggest breaks the intended pattern which spells trouble. You class mightn't be tightlight coupled, but it is more tightly coupled and this is a factor in maintainability. The eventing mechanism is just plain cleaner.
|
|
|
|
|
Keith Barrow wrote: The eventing mechanism is just plain cleaner.
Maybe, depending on the OP's needs. Could you give a clear code example of what you are envisioning?
|
|
|
|
|
I'm not going to code it (1am here & I don't need the head-fry), but the process is simple enough:
1. Add an event to the masterpage, DatagridChanged or somesuch
2. The child subscribes to the event
3. When the datagrid on the masterpage is changed , the the event is raised and the subscribed handler does the work on the child.
Note the MasterPage is totally agnostic of the the Child, giving pure decoupling in that direction and the child can access any data it might need from the master page. You can even probably hook into the datagrid's own events, even neater.
[edit]
Also note I have corrected what I originally said: I got it totally wrong, it was 1:20am after all. now I'm off to the land of nod.
|
|
|
|
|
through means of below code i add radiobutton to my gridview.
grdFeedback.DataSource = ds;
grdFeedback.DataBind();
foreach (GridViewRow row in grdFeedback.Rows)
{
if (row.Cells[3].Text == "" && row.Cells[4].Text == "" && row.Cells[5].Text == "" && row.Cells[6].Text == "" && row.Cells[7].Text == "")
{
TextBox txtAns = new TextBox();
txtAns.ID = "txtAns";
row.Cells[3].Controls.Add(txtAns);
}
else
{
for (int c = 3; c <= 7; c++)
{
if (row.Cells[c].Text != " ")
{
RadioButton rbtn = new RadioButton();
string rbt = "rbtngrp";
string opt = row.Cells[c].Text;
rbtn.ID = rbt + row.RowIndex + c;
rbtn.Text = opt.ToString();
rbtn.GroupName = rbt + row.RowIndex;
row.Cells[c].Controls.Add(rbtn);
}
}
}
}
how to check it whether the button is checked or not in an button click?. The below code i used. but its error : 'grdFeedback.Rows[0].Cells[4].Controls[2]' threw an exception of 'System.ArgumentOutOfRangeException' bool {System.ArgumentOutOfRangeException}
((CheckBox)(grdFeedback.Rows[0].Cells[4].Controls[2])).Checked
|
|
|
|
|
First of all, you shouldn't be finding controls by indices. For one thing, it is confusing. Moreover, if you changed the order of your columns, you'll end up breaking your code.
Instead, use the row.FindControl method.
Another thing to check for the row type, since a grid may have several row types (header/footer/data/..)
So while you checkbox exists in the DataRow, it doesn't exist in the header row for example, which in turn probably causes your exception.
So you should do something like this:
foreach (GridViewRow row in grdFeedback.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
RadioButton btn=row.FindControl("RadioButton_ID_Goes_Here") as RadioButton;
bool isChecked = btn.Checked;
}
}
|
|
|
|