|
You need to add some sort of trigger or button, and double click on it to wire up a command function.
in the command function, as the control for the selected value
if page.ispostback
dim iValue as Integer
iValue = controlName.SelectedValue
if iValue > 0 Then
|
|
|
|
|
Thank you for your reply. After doing some changes, my new questions now are the ones shown on the message below. Please let me know your suggestions.
|
|
|
|
|
Hi,
For displaying scroll bar in grid view you can use an asp:panel.
<asp:panel id="pnlGrid" runat="server" <b="">Scrollbars="Vertical"/>
On The Edit button click you can use another panel and show it when you edit a grid view row.
This panel would consists of text boxes which would display the selected row's details in brief.
You can use grid view rowcommand event for displaying details of the selected row
<asp:templatefield headertext="ID">
<itemtemplate>
<asp:linkbutton id="lnkbtnEdit" runat="server" commandargument="<%#Eval("ID")%>" commandname="Select">
Note:Eval is a databinding expression.
You can maintain the datasource in session
and filter values in datasource based upon the command argument.
protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="Select")
{
string ID=Convert.ToString(e.CommandArgument.ToString());
DataView gridviewData=(DataView)this.Session["DS"];
DataRow[] selectedRow = gridviewData.Table.Select("ID=" + ID);
if (selectedRow[0] != null)
{
DataRowW currRow=selectedRow[0];
txtEmailadd.text=currRow["EmailAdd"].tostring();
}
}
}
<div class="signature">Cheers
SyedMuneem</div>
|
|
|
|
|
 Hello, SyedMuneem.
My current code is shown below. I could see the vertical scrollbar in case there are many corresponding records to be display. My other questions now are:
(1)When I scroll up or down, the very first header line moves up or down also. How do I make the very first header line fixed?
(2)The very last column, the PersonSeq, if I click, I am actually displaying another form from which I can edit the various fields that can be edited.
What I would like to do finally is get rid or hide that PersonSeq column and be able to click on or select any row just like any row in a scrollable textbox.
And once I have clicked on or selected any row, if I would like to edit that currently selected row, I would just click one "EDIT" button at the very bottom of the panel(?) and then that is when I would like to call that separate form for editing the details of that selected. How do I do this, and how do I pick up the PersonSeq of the row/record that I clicked (or selected) on so I could pass it to that separate form for editing. The point is I do not want to use the gridview's provided edit/select buttons that are on each row or record of the gridview.
<asp:Panel ID="Panel1" runat="server" ScrollBars="Auto" Width="100%" Height="350px">
<asp:GridView ID="gridViewPersonInfo" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None"
onselectedindexchanged="gridViewPersonInfo_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="EmailAddress" HeaderText="Email Address" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" ReadOnly="True" />
<asp:BoundField DataField="FirstName" HeaderText="First Name" ReadOnly="True" />
<asp:ButtonField CommandName="Select" DataTextField="PersonSeq"
HeaderText="Person Seq" Text="Button" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</asp:Panel>
|
|
|
|
|
Would love to help, but I don't do gridview questions.
|
|
|
|
|
Hi
I have a field in database that contain both text and image I want to display this field in gridview please help me.

|
|
|
|
|
|
In This case that you mention you have a field that only contain picture but I have one field that contain picture and text like this "This is test as an example" when I bound it to gridview it doesn't show me the image and gridview treat with this case like a text so what can I do to solve it?
|
|
|
|
|
actually, i'm using updatepanel at my asp.net page because i need the partial refreshing at my page.
my page including 3 parts. at the first it just shows the top menu, once user clicks on any of the top menu it will shows the left sub menu and by clicking on any of the sub menu it will shows the content of the sub menu, which is including table with add, edit, delete and insert button. for the table i have used the listview.
Now i want to show one external page at the 3rd panel, which means when the user click on the sub menu the 3rd panel load the another page. for example my page name is default.aspx and once the user click on the sub menu at the default.aspx page it shows the Product.aspx page at the 3rd panel. i don't want to use the iframe and i have gone through uframe at the http://uframe.codeplex.com and http://www.codeproject.com/KB/aspnet/uframe.aspx but i couldn't use the uframe at my page.
Could you please guide me how to use uframe at my page or any other way to load the other page at the 3rd panel of my default.aspx.
appreciate your consideration.
|
|
|
|
|
If you need help with something from codeplex you should ask there.
You could use JQuery load to get the other page but there may be good deal of work necessary to extract the actual content you want rendered. Iframe would be the best implementation.
No comment
|
|
|
|
|
i have done a web page but i have a problem...i already make a waveform graph and the buttons to control the graph in different window...my problem now is i want to make the buttons to control the graph and the graph in the same window... i try to make it in the same window but i can not refresh the graph...anyone can help me to solve my problem?i want the graph always refresh and the button still have in the window and do not refresh with the graph....
|
|
|
|
|
Pick one forum and use it don't post the same question multiple times
No comment
|
|
|
|
|
I'm trying to reference the attributes of a panel in a User Control in the code behind of a web page. I've tried about a dozen variations. Can't be this hard. Anybody got the correct syntax? Thanks!
<%@ Register Src="~/inc/ceSteps.ascx" TagName="ceSteps" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<uc1:ceSteps ID="ceSteps" runat="server" />
Then in the page's code behind, here's where I get stuck.
Dim myCtrl As UserControl = CType(FindControl("uc1"), UserControl)
myCtrl.pnlStage1.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
yahda, yahda, yahda....
|
|
|
|
|
The register is the webform side of the dll.
<uc1:sample>
The code side is something like, ceSteps is the class name assigned to the program code you want to access.
Dim myCtrl As ceSteps = new ceSteps
ceSteps myCtrl = new ceSteps;
ceSteps *myCtrl = new ceSteps;
|
|
|
|
|
I kinda get what you're saying and I tried it, but it won't let me reference the class ceSteps as a namespace like I do when I import at the top of the page (say for my login code) and then reference an instance of a namespace. I've used the code below before in another app, honest, but it's not working and I'm stumped.
Dim myPnl As Panel = CType(CType(FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
|
|
|
|
|
I also thought it might be because I was missing the reference through the master/content relationship, but that wasn't it:
Dim myConPH As ContentPlaceHolder
myConPH = CType(FindControl("SSLmaster_ContentPlaceHolder1"), ContentPlaceHolder)
Dim myPnl As Panel = CType(CType(myConPH.FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
|
|
|
|
|
I wasn't able to see your user control.
With user controls, like server controls, you don't use the code behind pages on the webform to interact with them. Instead, you write more code in your user control.
So just register the control in the webform like you did. Then if you want to do something in page.load, you add an override to your user control.
Public Class MyControl
Private lbl_Website_Name As Label
Protected overrides Sub OnInit(ByVal e as System.EventArgs)
controls.clear
lbl_WebsiteName = New Label
With lbl_Website_Name
End With
Controls.Add(lbl_Website_name)
End Sub
Protected overrides Sub OnLoad(ByVal e As System.EventArgs)
Do you stuff.
lbl_Website_Name.txt = sWebsiteName
End Sub
This will append to the current page.load on the web form, and operate identical to page load.
You can call the control by the name assigned,
|
|
|
|
|
 Sorry, that won't work for me - I need to do so from the child webpage. Let me try and be a little more precise, maybe that will help. I really think it's something to do with master/child since I was able to successfully reference one when not using the master.
Master:
<%@ Master Language="VB" CodeFile="SSLmaster.master.vb" Inherits="master" EnableTheming="true" %>
<body>
<form id="form1" runat="server" enableviewstate="true"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
yahda, yahda, yahda...
Child:
<%@ Page Title="yahda" Theme="SSL" Language="VB" MasterPageFile="~/inc/SSLmaster.master" AutoEventWireup="false" CodeFile="zdetail1.aspx.vb" Inherits="calendar_zdetail1" %>
<%@ Register Src="~/inc/ceSteps.ascx" TagName="ceSteps" TagPrefix="uc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
UserControl:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ceSteps.ascx.vb" Inherits="inc_ceSteps" %>
<asp:Panel runat="server" ID="Panel1" > Step 1 </asp:Panel>
CodeBehind of Child:
First Stab (successful on page without Master):
Dim myPnl As Panel = CType(CType(FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
Second Stab (and many more variations)
Dim myConPH As ContentPlaceHolder
myConPH = CType(FindControl("SSLmaster_ContentPlaceHolder1"), ContentPlaceHolder)
Dim myPnl As Panel = CType(CType(myConPH.FindControl("ceSteps"), UserControl).FindControl("Panel1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
|
|
|
|
|
Well, you use css to change the background color of the panel.
But I don't when you want to change the color.
On postback, in the server, or when creating the control
If you want to remove the existing css
MyPnl.Style.Remove(HtmlTextWriterStyle.backgroundColor)
If you want to add a style
MyPnl.Style.Add(HtmlTextWriterStyle.backgroundColor, "#dfdfdf")
|
|
|
|
|
 Sorry, that won't work for me if I can't reference the control to change the style. Understand the problem now? Let me try and be a little more precise, maybe that will help. I really think it's something to do with master/child since I was able to successfully reference one when not using the master.
Master:
<%@ Master Language="VB" CodeFile="SSLmaster.master.vb" Inherits="master" EnableTheming="true" %>
<body>
<form id="form1" runat="server" enableviewstate="true"><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
yahda, yahda, yahda...
Child:
<%@ Page Title="yahda" Theme="SSL" Language="VB" MasterPageFile="~/inc/SSLmaster.master" AutoEventWireup="false" CodeFile="zdetail1.aspx.vb" Inherits="calendar_zdetail1" %>
<%@ Register Src="~/inc/ceSteps.ascx" TagName="ceSteps" TagPrefix="uc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
UserControl:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ceSteps.ascx.vb" Inherits="inc_ceSteps" %>
<asp:Panel runat="server" ID="Panel1" > Step 1 </asp:Panel>
CodeBehind of Child:
First Stab (successful on page without Master):
Dim myPnl As Panel = CType(CType(FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
Second Stab (and many more variations)
Dim myConPH As ContentPlaceHolder
myConPH = CType(FindControl("SSLmaster_ContentPlaceHolder1"), ContentPlaceHolder)
Dim myPnl As Panel = CType(CType(myConPH.FindControl("ceSteps"), UserControl).FindControl("pnlStage1"), Panel)
myPnl.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
|
|
|
|
|
I'm looking at your markup code, I understand the markup code,
But I have no idea what your trying to achieve. What the steps are, the purpose of changing the color, when and where.
My interpretation is that you want to find the asp.net ID of the panel control in the child webform, make a handle to it, and change the background color of the panel.
Not the Answer but here's how it works::
When adding a master page, the id of the control will be prefixed with CT_100_ or CT100_
That's the only difference between the 2 scenarios. MasterPage will also start to auto ID your controls, if you don't assign a ID manually. In other words, when you master page, asp.net will automatically fix all your control id's so it can find and track the controls, and disregards your need to find them. Every control has to have a unique ID, and no one can be the same.
So myPnl becomes CT_100_myPnl if you assign the ID atribute. If you don't assign the ID attribute, asp.net will assign a senquential auto naming ID code to the control object, and find control will never find it.
Naming Practices:
When naming a control in a user control, you can use ID = [ID] & "_myPnl", which produces CT_100_ceSteps_myPnl
This will stop the auto id's of your controls, so you actually are in charge of naming your objects.
Diagnostics:
So look at the html that was created by the server in the browsers source, in both with and without master page, and write down the control id or each one. And put that exact name in find control. Oh, ever the placeholder name will change as well.
I haven't used find control in years, and I abandoned the use of it, and have forgotten how to use it in master pages. Over the years I learned how to access any object on the page, at the right time and place, so that's not an issue for me anymore.
|
|
|
|
|
The problem is that UserControl has no pn1Stage1 member...
In the first line, you're specifying that myCtrl is of type UserControl. In order to access a specific property of YOUR user control, you need a variable of that type...something like...
Dim myCtrl as MyControlType = CType(FindControl("ceSteps", MyControlType))
The trick is that FindControl returns a Control type, which you then cast to the correct type.
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Thanks for the reply, Richard. Tried it, but no go. I still think it has something to do with those pesky Master pages. Again, the one I've been using without Master Pages works fine... Got the same error.
Dim myCtrl As UserControl = CType(FindControl("ceSteps1"), UserControl)
Dim myPnl As Panel = CType(myCtrl.FindControl("pnlStage1"), Panel)
myPnl.BackColor = Drawing.Color.Azure
|
|
|
|
|
I found this, and I kinda get what they're saying, but I can't get it to work either.
tip18843
Protected MyCtl As Panel
Private Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Init
MyCtl = DirectCast(FindControl("pnlStage1"), Panel)
End Sub
Protected Sub btnStep2b_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStep2b.Click
MyCtl.BackColor = Drawing.Color.Azure
End Sub
|
|
|
|
|
Since I am having so many problems with using a detailsview 2010 control, I am going to convert my logic to use a formview control instead. Thus can you tell me if there is a referenceon on how to convert and/or copy detailsview code to formsview code?
Basically I am going to take the itemtemplate and editiemtemplates and hopefully use them in the formwview control.
I will place the update and clear buttons outside of the formsview control but on the webform page. Thus to be able to update the data on the buttons outside of the the formsview would I use a updateitem method or some other method?
|
|
|
|