|
Is it possible to open a popup window on right click on a row of a datagrid at
client side?
SAM.
|
|
|
|
|
Yes, it is. You can look at the oncontextmenu[^] event, and lots of datagrid examples from this girl[^]
|
|
|
|
|
|
In C#, .NET 2.0. I have a gridview in frm_Report which looks like this.
i have used the sqldatasource to bind the data.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Stud_Admin" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Stud_Admin" HeaderText="Stud_Admin" ReadOnly="True" SortExpression="Stud_Admin" />
<asp:BoundField DataField="Stud_Name" HeaderText="Stud_Name" SortExpression="Stud_Name" />
<asp:HyperLinkField HeaderText="" Text="View" DataNavigateUrlFields="Stud_Admin" DataNavigateUrlFormatString="frm_StudReport.aspx />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FYPJ_TestDBConnectionString2 %>"
SelectCommand="SELECT [SN], [Stud_Admin] FROM [Stud_Particulars]">
</asp:SqlDataSource>
In my another form frm_Show is basically this.
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
When user select the hyperlink View, the hyperlink will grab value of Stud_Admin of the selected row in gridview and display it at Label1. What is the next code should I add?
thanks in advance. Much appreciated.
|
|
|
|
|
use Row.RowIndex property to get the selected row..
use RowCommand event of GridView.
Regards,
Jay
|
|
|
|
|
I don't know what to do next. By getting the values, how will the hyperlink be clever to pass value to label in another form. And what is the syntax for Label1.text = ? By using findcontrol?
And
protected void GridView8_RowCommand(object sender, GridViewCommandEventArgs e)<br />
{<br />
GridViewRow row = GridView8.Rows[0];<br />
}
thanks in advance. Much appreciated.
|
|
|
|
|
If the Stud_Admin text is simple, you may consider passing the value along with the url in the query string (set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )so that you can get it from the Request object in the next page . In addition, you still have many other choices:
+ Try to retrieve again in DB based on the id passed from the source page when the text is long.
+ Try to use the LinkButton, so before redirecting to the next page you can save the text in the Session.
|
|
|
|
|
Thank you. It works.
minhpc_bk wrote: (set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )
But I was just wondering what does Stud_Admin={0} means?
If I want to pass two values which is Stud_admin and the next column just next to Stud_Admin? What will the longer DataNavigateUrlFormatString = be?
thanks in advance. Much appreciated.
|
|
|
|
|
|
I still don't understand.
I am using codebehind. And initially i can fetch one data from the gridview to another webform and display it in the label.
I want to experiment and fetch two datas from the gridview to another webform and display it in the label.
<Columns>
<asp:BoundField DataField="Stud_Admin" HeaderText="Admin No" ReadOnly="True" SortExpression="Stud_Admin" />
<asp:BoundField DataField="Stud_Name" HeaderText="Student Name" SortExpression="Stud_Name" />
<asp:HyperLinkField Text="View" DataNavigateUrlFields="Stud_Admin" DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}"/>
</Columns>
And another webform at the page load,
<code>Label1.Text = Request.QueryString["Stud_Admin"];</code>
How can I fetch the Stud_Name as well and display it in Label2.text?
thanks in advance. Much appreciated.
|
|
|
|
|
Well, the explanation in MSDN is clear enough:
+DataNavigateUrlFields="Stud_Admin,Stud_Name" (seperated by comma)
+DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the & )
|
|
|
|
|
Thanks many-many.
minhpc_bk wrote: +DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)
Though this should be right,
DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={1}"
thanks in advance. Much appreciated.
|
|
|
|
|
Ahh, that's my trap to challenge you .
Oops, my copy-paste error
|
|
|
|
|
I solved and solved, luckily I can solved.
GOOd one over there!
please be careful newbies. haha.
|
|
|
|
|
Help!
I need to force a postback...
The reason why is, I am using a Menu, and I have configured the StaticSelectedStyle for it, and it works fine, until I set a NavigateURL for the menu items! According to a Microsoft article, when there is a NavigateURL set, and the menuitem is clicked, it navigates to the new page, and does not perform a postback... so the StaticSelectedStyle does not get called, and my menu does not get updated...
Here's the article I'm referring to:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.menuitem.aspx
Here's the info from the Microsoft article:
When the user clicks a menu item, the Menu control can either navigate to a linked Web page or simply post back to the server. If the NavigateUrl property of a menu item is set, the Menu control navigates to the linked page...
Thanks so much for your help!
|
|
|
|
|
try with ...
if(Page.IsPostBack)
{
//set of code to be executed during Postback
}
Regards,
Jay
|
|
|
|
|
Hi,
glima wrote: If the NavigateUrl property of a menu item is set, the Menu control navigates to the linked page...
Its simple. Dont set the NavigateURL. Then according to the above info, it will post back. Here you call whatever functions u want to and then use Response.Redirect("URL")
You can try it (atleast)
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
Because it navigates to a new page so the menu control does not remember the current selected item, in this case you simply check the current url then set the selected menu item accordingly.
|
|
|
|
|
Hi ,
I'm creating a custom control for a web project. I wanted to add flash content as part of that control. How do i do that in C# file. Pls help.
Thanks in advance,
Priya
|
|
|
|
|
Dpriya wrote: I wanted to add flash content as part of that control.
You mean you want to add the html markup to the custom control so that when it is used on the web page the player can run at the client side? Basically, you can add the contents to the custom control in the Render method or add the child control to the Controls collection of the parent.
|
|
|
|
|
How do i make the scrollbar to appear in datagridview
How do i make the DataGridView Readonly
|
|
|
|
|
kalyanPaladugu wrote: How do i make the scrollbar to appear in datagridview
The way you do with the GridView control is similar to the datagrid[^] control.
kalyanPaladugu wrote: How do i make the DataGridView Readonly
The simple way is not to use any editable control in the GridView control, for example with the BoundField you can set the ReadOnly to true ....
|
|
|
|
|
Hi guys iam trying to sorting in the gridview.But its not working its asking me to implement the onsorting event which i am unable to figure out wht to be in that event.I tryed to sort like we used to do in 1.1 but its not working.If any one of u implemented sorting help me with code snippet or guidelines.Thank you.
|
|
|
|
|
Set the AllowSorting property to true. If you don't have any command fields in your gridview, you might want to set the EnableSortingAndPagingCallbacks property to true as well to get a better performance.
Nila
|
|
|
|
|