|
hi
my code is like this
outputText += "";
outputText += "";
protected void lnk_Click(object sender, EventArgs e)
{
}
so this is not fire, could help me to fire this event.
|
|
|
|
|
where you have assigned this event lnk_Click on aspx page
Cheers!!
Brij
|
|
|
|
|
hi
i solved my problem, i have put href for A tag with query string, from redirect page i retrieve that query string and do other stuff,
when u put onclick also it wasn't work for me
Thanks
|
|
|
|
|
Hello,
I am trying to get the data from a cell in a GridView. I am using the following RowCommand event to do this.
protected void GridViewResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow gvr = GridViewResults.Rows[Convert.ToInt32(e.CommandArgument)];
string pdf = gvr.Cells[6].Text;
}
An exception is thrown on the first line of code. Debugging this line shows that the code does return the selected row number as the command argument, however, it also returns the following error:
ArguementOutOfRangeException:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
I am confused about which index is returning the error! The only index I am aware of from this line of code is the number of rows in the grid, and that number is returned correctly regardless of the users row selection (as checked in the debugger) and is always non negative. I have been 3 days and all over the Internet trying to get an answer to this. ANY assistance is greatly appreciated.
Thank you for your time, Pat
|
|
|
|
|
Try to get the text as below
e.Row.Cells[index].Text
index: it is the cell index and starts from zero
Cheers!!
Brij
|
|
|
|
|
Brij,
Thank you for the quick reply. I applied your code as follows. Below is the complete error message returned:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 476: protected void GridViewResults_RowCommand(object sender, GridViewCommandEventArgs e)
Line 477: {
Line 478: string pdf = GridViewResults.Rows[Convert.ToInt32(e.CommandArgument)].Cells[6].Text;
I have also reduced the Cells value to [1] (there are 7 columns) just to make sure that I was not out of the Cell column range. I am a bit surprised that there is no "text overload" as an option as there is in C# desk application. The error is the same. Please let me know if you have any other ideas or if I am applying your code incorrectly. Thank you again for your input. I really need to get this done today.
Best Regards, Pat
|
|
|
|
|
Can you post your gridview control's code that is in aspx page?
Cheers!!
Brij
|
|
|
|
|
Yes, Absolutely.....
<asp:GridView ID="GridViewResults" runat="server" CssClass="gridViewSpecs"
HeaderStyle-Height="30px" Height="100px" Width="770px" BackColor="White"
RowStyle-Height="25px" onrowcommand="GridViewResults_RowCommand">
<RowStyle Height="25px" />
<HeaderStyle Height="30px"></HeaderStyle>
<HeaderStyle BackColor="#CCCCCC" />
<Columns >
<asp:buttonfield
commandname="getPdf"
Text="Select" HeaderImageUrl="~/Graphics/adobe2.PNG" />
</Columns>
</asp:GridView>
Thank you again for your follow up.. ...MUCH appreciated!
Pat
|
|
|
|
|
Hello Pat
Instead of using
GridViewRow gvr = GridViewResults.Rows[Convert.ToInt32(e.CommandArgument)];
string pdf = gvr.Cells[6].Text;
use
Button button= (Button)e.Row.Cells[0].Controls[0];
as you are having button in column 0.
let me know when done
Cheers!!
Brij
|
|
|
|
|
Hi Brij,
Well, this is one that I have never seen before (perhaps I am leading a sheltered life...?.. .
OK, I put that in and got this new error:
Compiler Error Message: CS1061: 'System.Web.UI.WebControls.GridViewCommandEventArgs' does not contain a definition for 'Row' and no extension method 'Row' accepting a first argument of type 'System.Web.UI.WebControls.GridViewCommandEventArgs' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 481: if (e.CommandName.Equals("getPdf"))
Line 482: {
Line 483: Button button = (Button)e.Row.Cells[0].Controls[0];
Line 484:
Line 485:
Could I be missing a using directive for this to compile?. Below is a copy of the using directives for this page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
using System.Diagnostics;
Thanks Brij...Pat
|
|
|
|
|
|
Hi all,
I want to use jquery for making the picture zoom,how can i do it.
Thanks in advance.
|
|
|
|
|
|
There is excellent tool named as fancybox.
Click Here to get details.
I have used this its really great.
Cheers!!
Brij
|
|
|
|
|
hello brother
Just i want to know
Page 1 of 66 [1 2 3 4 5 6 7 8 9 10 ]First · Prev · Next
this above line is there right tell me how can i do same in bottom of gridview
Some Thing need 2 do NEW
|
|
|
|
|
Good Day Rajeshwar
I really dont undestand you well, i think you mean you know to know how to do paging in ASp.net ?
here is how its done
Paging without a wizard (SqldataSource control) [^]
Hope it Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Thanks brother ,
i used code what is there in ur article , in VS 2008 what code i use for paging.
Some Thing need 2 do NEW
|
|
|
|
|
You are Welcome
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
why dont you use
<asp:DataPager ID="dpage" runat="server">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
Easy isnt it?
|
|
|
|
|
plz tel me how to resolve that error
my code is
<asp:GridView ID="gridView" runat="server" Style="position: relative; left: 299px; top: 69px;" PageSize="5" OnRowCommand="gridView_OnRowCommand" AllowPaging="True" OnSelectedIndexChanged="gridView_SelectedIndexChanged1" >
<PagerTemplate>
<% if (gridView.PageIndex > 0)
{ %>
<asp:ImageButton ID="imgBtnPrevious" runat="server" Style="vertical-align: middle;" ImageUrl="pre.jpg" OnClick="click1"
CommandArgument="Prev" CommandName="Page" />
<% } %>
<%=(gridView.PageIndex * 5) + 1%> <%=(gridView.PageIndex * 5) + gridView.Rows.Count%>
<% if (gridView.PageIndex != (gridView.PageCount - 1))
{ %>
<asp:ImageButton ID="imgBtnNext" runat="server" Style="vertical-align: middle;" ImageUrl="next.jpg" OnClick="click" CommandArgument="Next" CommandName="Page" />
<% } %>
<%--<asp:ImageButton ID="imgBtnNext" runat="server"
Style="vertical-align: middle;" ImageUrl="next.jpg"
CommandArgument='<%# Eval("Next")%>' OnClick="click" CommandName="Page" />--%>
</PagerTemplate>
</asp:GridView>
</asp:Panel>
<%--<%=(gridView.PageIndex * 5) + 1%> <%=(gridView.PageIndex * 5) + gridView.Rows.Count%> --%>
<% if (gridView.PageIndex != (gridView.PageCount - 1))
{ %>
<asp:ImageButton ID="imgBtnNext" runat="server" Style="vertical-align: middle;" ImageUrl="next.jpg" OnClick="click" CommandArgument="Next" CommandName="Page" />
<% } %>
<%--<asp:ImageButton ID="imgBtnNext" runat="server"
Style="vertical-align: middle;" ImageUrl="next.jpg"
CommandArgument='<%# Eval("Next")%>' OnClick="click" CommandName="Page" />--%>
</PagerTemplate>
</asp:GridView>
and code behind is
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlDataAdapter adapPaging = new SqlDataAdapter("select * from customer", "Data Source=OPWFMS-7KYGZ7SB;Initial Catalog=Mayank;User ID=sa;Password=sa");
adapPaging.Fill(ds);
gridView.DataSource = ds;
gridView.DataBind();
}
public void click1(object send, ImageClickEventArgs e)
{
GridViewPageEventArgs obj = new GridViewPageEventArgs(gridView.PageIndex - 1);
gridView.PageIndex = obj.NewPageIndex;
LinkButton exmp = new LinkButton();
exmp.Text = "exmp";
Panel1.Controls.Add(exmp);
}
public void click(object send, ImageClickEventArgs e)
{
GridViewPageEventArgs obj = new GridViewPageEventArgs(gridView.PageIndex+1);
gridView.PageIndex = obj.NewPageIndex;
}
}
|
|
|
|
|
Seriously your code is not readable. Please post it in proper Format
As For Example :
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlDataAdapter adapPaging = new SqlDataAdapter("select * from customer", "Data Source=OPWFMS-7KYGZ7SB;Initial Catalog=Mayank;User ID=sa;Password=sa");
adapPaging.Fill(ds);
gridView.DataSource = ds;
gridView.DataBind();
}
so that every body can easily understand the code and give you a quick solution.
pupilstuff wrote: Subject: error : panel1 does not exits in correct context
It clearly saying that Panel1 does not exist
|
|
|
|
|
I am not able to see the panel on the page.where is it?
Cheers!!
Brij
|
|
|
|
|
It is very hard to understand code blocks when there are lots of Server Tags and even most of them are Commented out.
I can see in designer of your html most of the codes are commented out using
<%-- --%>
and also if you have placed a Panel1 in html, please let us see the control in designer.
If you need to use a control Panel1 you need to add
<asp:panel id="Panel1" runat="server">
in your designer, also this shouldnt be within <%-- --%> tag
|
|
|
|
|
hiii
i have created a menu dynamically.i have populated the menuitems from data base.
Now i want that whenever user clicks particular menu item it gets redirect to particular page.
can any body guide me regarding this matter.........
thanks....
|
|
|
|
|
Are you using Asp:Menu, if so use
MenuItem item = new MenuItem("MyItem");
item.NavigateUrl = "yoururl.aspx";
If you are generating the HTML dynamically for menu, just place OnClick attribute for the LI/div item
|
|
|
|