|
Since you have defined the control inside grid u have to create the checked event, ex-
<asp:GridView ID="grdSearch" runat="server" Width="100%">
<Columns>
<asp:TemplateField HeaderText="FirstName">
<ItemTemplate>
<asp:LinkButton ID="lbtnFName" runat="server" Text='<%# eval("fname") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code behind-
Protected Sub grdSearch_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdSearch.RowCreated
Dim LinkButton1 As LinkButton
Select Case e.Row.RowType
Case DataControlRowType.DataRow
LinkButton1 = CType(e.Row.FindControl("lbtnFName"), LinkButton)
AddHandler LinkButton1.Click, AddressOf lnkApptBtn_Click
End Select
End Sub
'Handler function
Protected Sub lnkApptBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim lngPcpid As Long
Dim lnkbtn As LinkButton = CType(sender, LinkButton)
Dim objItem As GridViewRow = CType(lnkbtn.Parent.Parent, GridViewRow)
Dim intSelectedRow As Integer = CInt(objItem.RowIndex.ToString())
lngPcpid = Trim$(grdSearch.Rows(intSelectedRow).Cells(4).Text)
End Sub
U just have to change the link button event to radio button event
All the best
|
|
|
|
|
Im looking for documents(programming languages) that would guide me in creating an interface that reads network data. So i guess i should start by creating the interface or finding out how to read network data and input database.
|
|
|
|
|
Hello all.
I'm working with a Web Application on IIS6 and ASP.NET 2.0, on a Windows 2003 server. This app has a class that implements the IHttpModule interface. So far, it overrides the HttpApplication.Context.Filter property to perform some filters on the data being streamed. The class looks something like the following:
public class PageCleanerStream
{
}
public class PageCleanerHttpModule : IHttpModule
{
PageCleanerHttpModule() { }
public void Dispose() { }
public void Init(HttpApplication context)
{
context.PostRequestHandlerExecute += new EventHandler(
delegate(object sender, EventArgs args)
{
if (sender is HttpApplication)
{
using (HttpApplication app = sender as HttpApplication)
{
if (app.Context.CurrentHandler is Page)
app.Response.Filter = new PageCleanerStream(app.Response.Filter);
}
}
}
);
}
}
Of course, I have my web.config properly configured and so far everything works as expected: the filter performed by PageCleanerStream does its work well.
Now, I have a new requirement stating that such filter should not be performed on a particular page (i.e. when "somepage.aspx" is requested the filter should not apply. So, I thought it was only a matter of getting the URL of the page being requested and see if it matches "somepage.aspx".
However, I haven't found a way of getting such URL. So far, I've tried three approaches.
1. Cast app.Context.CurrentHandler to a Page , and if not null, then check the Url property. Something like:
Page page = app.Context.CurrentHandler as Page;
if (page.Request.Url.GetLeftPart(UriPartial.Path).IndexOf("somepage.aspx") < 0)
app.Response.Filter = new PageCleanerStream(app.Response.Filter);
This fails because at the time the event is invoked the page.Request object is unavailable.
2. Get the URI property from HTTP headers, as:
if ((app.Response.Headers["URI"]).IndexOf("somepage.aspx") < 0)
app.Response.Filter = new PageCleanerStream(app.Response.Filter);
This approach fails too since it throws a PlatformNotSupportedException , saying that such property requires IIS 7 and .NET Framework 3.0, and at the time, changing the environment is not an option.
3. Finally, I tried calling the HttpResponse.RedirectLocation , yet it returns a null .
So now I'm out of ideas, other than ask for help and keep googling to see if I can find something useful. So... under this scenario, does someone know how could I determine the page's URL being
requested? I'm opened to new approaches as well.
Any clue will be really appreciated.
Thanks in advance.
Stupidity is an International Association - Enrique Jardiel Poncela
|
|
|
|
|
hello,
I have the same problem.
Did you solve this issue?
thank oyu
|
|
|
|
|
Hi there. Unfortunately, nope, I couldn't solve it. I had to re-orginze my entire code so that I would not depend on such feature.
Cheers and good luck.
Stupidity is an International Association - Enrique Jardiel Poncela
|
|
|
|
|
thank you
E.
|
|
|
|
|
Hi,
I am using a Button column command to fire an event. I assumed that when the button is clicked, the SelectedIndexChanged event would fire and then run some code, since there is no actual 'click' event....but it does not. I thought that this might be due to an AutoPostback setting, but I cannot find one for the GridView control. If there is one, or if there is another way to do this, I would appreciate if someone could explain it to me, as well as what causes the SelectedIndexChanged event to fire.
Thank You, Pat
|
|
|
|
|
Dear all,
Im using a gridview to show some data from my db table(sql server 2008 express).
I want to show two columns of my table : 'id' and 'eventText' . Bud because the 'eventText' column can have a lot of text, i want to show only some of it in the gridview with a hyperlink 'read more'. Clicking on 'read more', brings the user to other page and shows the entire text of the selected row.
Im very new with this and hope you can help me.
Thanks.
|
|
|
|
|
You need to write a custom binding that formats the text to show it the way you want it to, with a link to the other page.
Is this homework ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for rewriting my question as answer...yes it's homework.
|
|
|
|
|
Priya Prk wrote: Thanks for rewriting my question as answer...yes it's homework.
That sounds bad. Really bad!
|
|
|
|
|
Priya Prk wrote: Thanks for rewriting my question as answer...yes it's homework
Please don't reply like this from next time. Try to understand what was the meaning of that answer.
|
|
|
|
|
I got it now, thanks for helping guys
|
|
|
|
|
Hi All,
Please let me know whether we can call functions of a win32 dll from a ASP.Net.
Regards,
Ashwath Hegde
|
|
|
|
|
Please don't Cross Post. If your last post was wrong then modify it. Don't RePost.
|
|
|
|
|
|
If this is a new question then your other one was off topic. You're basically asking the same thing, which is rude.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yes, of course you can. Just use p/invoke.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have a checkbox in a template field in a gridview.
<asp:TemplateField HeaderText="test templet">
<ItemTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True"
Checked='<%# Bind("Archived") %>' oncheckedchanged="CheckBox2_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
Oncheckedchanged calls a code behind subroutine. I need to pass that subroutine the GridView datarow index so I can do some test on that particular record. I can’t seem to figure out how to do that.
Thanks
|
|
|
|
|
Where is your code behind code ?
|
|
|
|
|
I just figured it out -
simple....
Protected Sub CheckBox2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim gvRow As GridViewRow
Dim chkbx As CheckBox
Dim intRowIndex As Integer
chkbx = sender
gvRow = chkbx.Parent.Parent
intRowIndex = gvRow.RowIndex
' perform work agains that row here
end sub
Thanks for the reply.
|
|
|
|
|
Hi All,
Please let me know whether we can call functions of a win32 dll from a vb.net application.
Regards,
Ashwath Hegde
|
|
|
|
|
ashwath1979 wrote: Please let me know whether we can call functions of a win32 dll from a vb.net application.
In ASP.NET ?
|
|
|
|
|
Cheers to all the mavens out there on codeproject!
I've banged my head over this one for some time, and I don't understand the reason for this FormatException (log entry) as thrown by Convert.ToInt32 that uses an input value from an ASP .NET 2.0 form *with* validation:
ERROR 16 Jul 2009 09:01:13,970 (Webpage code-behind class name) - Failed conversion of value
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at (name of calling function in ASP.NET code-behind)
The code-behind of the web page is as follows:
try
{
dataObject.Weight = Convert.ToInt32(txbWeight.Text);
}
catch (Exception e)
{
log.Error("Failed conversion of value", e);
}
And the web page has the following validation for the txbWeight TextBox control:
<asp:CompareValidator runat="server" ControlToValidate="txbWeight" Type="Integer"
Operator="GreaterThanEqual" ValueToCompare="0" Text="Positive number only for weight."
Display="Dynamic" />
I don't understand why this exception is thrown, because the validator ensures that an integer is being received from the user (txbWeight also has a RequiredFieldValidator). The odd thing is that dataObject receives the value despite the exception being thrown!? I don't believe I need to call Trim(), and trying this in the past did not fix the issue.
Any ideas?
|
|
|
|
|
Always use int.tryparse, not convert.toint32. Do you have text in there, do you need to tell the validator to accept an empty field ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|