|
hey sandeep
when i add grid on page init it do not generate new row inside grid
|
|
|
|
|
hey sandip this is my
.aspx page
]]>
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>Untitled Page
function setHidVal(val)
{
debugger;
var ob=document.getElementById('tshf');
if(val=='Save')
{
ob.value=val;
}
else if(val=='AddRow')
{
ob.value=val;
}
}
<asp:scriptmanager id="ScriptManager1" runat="server">
AsyncPostBackTimeout="360"/>
<asp:label id="lblmy" runat="server">
<asp:updatepanel id="UpdatePanel1" runat="server">
<contenttemplate>
<asp:hiddenfield runat="server" id="tshf" value="">
<asp:gridview id="grdnew" runat="server" enableviewstate="true">
Style="z-index: 100; left: 53px; position: absolute;top: 81px"
CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="false">
<footerstyle backcolor="#990000" font-bold="True" forecolor="White">
<rowstyle backcolor="#FFFBD6" forecolor="#333333">
<selectedrowstyle backcolor="#FFCC66" font-bold="True" forecolor="Navy">
<pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center">
<headerstyle backcolor="#990000" font-bold="True" forecolor="White">
<alternatingrowstyle backcolor="White">
<columns><asp:templatefield>
<headertemplate>
<asp:label id="lblimg" runat="server" text=" ">
<itemtemplate>
<asp:imagebutton id="btnimgadd" runat="server" imageurl="~/add.gif">
ToolTip="Add Row" OnClick="bUpdate1_Click"
OnClientClick="javascript:setHidVal('AddRow');" />
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label1" runat="server" text="Name">
<itemtemplate>
<asp:textbox id="TextBox1" runat="server">
EnableViewState="true" Text='<%# Eval("Name")%>' Width ="100px" />
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label2" runat="server" text="ContactNo">
<itemtemplate>
<asp:textbox id="TextBox2" runat="server">
EnableViewState="true" Text='<%# Eval("contactNo")%>' Width ="100px" />
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label3" runat="server" text="Email">
<itemtemplate>
<asp:textbox id="TextBox3" runat="server">
EnableViewState="true" Text='<%# Eval("email")%>' Width ="100px"/>
<columns><asp:templatefield>
<headertemplate>
<asp:label id="Label4" runat="server" text="Designation">
<itemtemplate>
<asp:dropdownlist runat="server">
DataTextField="DesignationName" DataValueField="pkDesignationID"
EnableViewState="true" ID="ddldesg" Width="100px">
<asp:textbox id="TextBox4" runat="server">
EnableViewState="true" Text='<%# Eval("designation")%>'
Width ="100px" Visible="false"/>
--%>]]>
<asp:button id="btnSave" runat="server" text="Save" onclick="btnSave_Click">
OnClientClick="javascript:setHidVal('Save');" />
<triggers>--%>]]>
<asp:asyncpostbacktrigger controlid="btnSave" eventname="Click">
<asp:updateprogress id="UpdateProgress1" runat="server">
AssociatedUpdatePanelID="UpdatePanel1">
<progresstemplate>
Getting Data From Server.....
|
|
|
|
|
You are not adding the GridView Dynamically to the Page
So don't get confused with my last posts
Now from my understanding you are adding rows using javascript and you want this added row at server side along with data ...
Let me tell you you are doing in wrong way
Javascript will add row at client side server don't anything what javascript is doing in client browser
Check this URL
http://gridviewguy.com/CategoryDetails.aspx?categoryID=7[^]
Or as you are uaing AJAX why dont you add line at server side
Search for it in google
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Sandeep actually i m using update panel and script manager for grid view
i m using javascript for only change the value of hiddenfield at the time when i click on that button.
then on page load i m checking the value of hiddenfield and call related function
can u tell where i m wrong
thanks
|
|
|
|
|
this is my aspx.cs page
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using MySql.Data.MySqlClient;
public partial class Default2 : System.Web.UI.Page
{
DataSet ds;
MySqlConnection mcon;
MySqlCommand mcmd;
MySqlDataAdapter mda;
DataTable dt;
DataRow dr;
protected void Page_Init(object sender, EventArgs e)
{
mcon = new MySqlConnection("Database=tsmdemo;Server= 172.16.1.22;uid=root;pwd=tops123;");
mcon.Open();
if(!IsPostBack)
{
btnAddRow();
btnAddRow();
fillddl();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
if (tshf.Value == "Save")
{
lblmy.Text = grdnew.Rows.Count.ToString();
savedata();
tshf.Value = "";
}
else if (tshf.Value == "AddRow")
{
lblmy.Text = grdnew.Rows.Count.ToString();
btnAddRow();
fillddl();
tshf.Value = "";
}
}
}
protected void btnAddRow()
{
dt = CreateDataTable();
grdnew.DataSource = dt;
grdnew.DataBind();
Session["TimeSheet"] = "AddNew";
}
protected void btnDisRow()
{
dt = (DataTable)ViewState["DataTable"];
grdnew.DataSource = dt;
grdnew.DataBind();
}
protected DataTable CreateDataTable()
{
DataTable dtvalues = (DataTable)ViewState["DataTable"];
if (dtvalues == null)
{
dtvalues = new DataTable();
dtvalues.Columns.Add(new DataColumn("", typeof(string)));
dtvalues.Columns.Add(new DataColumn("Name", typeof(string)));
dtvalues.Columns.Add(new DataColumn("contactNo", typeof(string)));
dtvalues.Columns.Add(new DataColumn("email", typeof(string)));
dtvalues.Columns.Add(new DataColumn("designation", typeof(string)));
ViewState["DataTable"] = dtvalues;
}
else
{
dr = dtvalues.NewRow();
dtvalues.Rows.Add(dr);
ViewState["DataTable"] = dtvalues;
}
return dtvalues;
}
protected void fillddl()
{
try
{
mcmd = new MySqlCommand("Select * from tbldesignation;", mcon);
mda = new MySqlDataAdapter(mcmd);
ds = new DataSet();
mda.Fill(ds);
if ((String)Session["TimeSheet"] == "AddNew")
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow row in grdnew.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddldesg");
ddl.DataSource = ds;
ddl.DataBind();
}
}
if ((String)Session["TimeSheet"] == "Getdata")
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow row in grdnew.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddldesg");
ddl.DataSource = ds;
ddl.DataBind();
TextBox temp = (TextBox)row.FindControl("Textbox4");
ddl.SelectedIndex = Convert.ToInt32(temp.Text);
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
ds.Dispose();
mda.Dispose();
mcmd.Dispose();
}
}
protected void savedata()
{
string cmdText;
try
{
lblmy.Text = grdnew.Rows.Count.ToString();
foreach (GridViewRow gdr in grdnew.Rows)
{
string name = ((TextBox)gdr.FindControl("TextBox1")).Text;
string contactNo = ((TextBox)gdr.FindControl("TextBox2")).Text;
string email = ((TextBox)gdr.FindControl("TextBox3")).Text;
int designation = ((DropDownList)gdr.FindControl("ddldesg")).SelectedIndex;
cmdText = "INSERT INTO tblempinfo VALUES ('"
+ name + "','" + contactNo + "','" + email + "'," + Convert.ToString(designation + 1) + ")";
mcmd = new MySqlCommand(cmdText, mcon);
mcmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
mcmd.Dispose();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
}
protected void bUpdate1_Click(object sender, EventArgs e)
{
}
}
|
|
|
|
|
Ankit i can't check what is going wrong with this
Try to debug the things and see wats happening
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Just run an event for each button then you will know which one has been selected
|
|
|
|
|
i know it but i want to prevent my data on grid
|
|
|
|
|
Hi,
I have a problem with a current project and the scroll position.
I have an AJAX enabled website using Visual Studio 2005 and ASP.Net 2.0.
The project also uses masterpages.
On the page in question, there is a search section in an AJAX update panel, situated on the left hand side. Upon submitting criteria and pressing a button, the results are displayed on the right hand side of the page.
On the right hand side of the page, there is another AJAX Update Panel. Within this Ajax Update Panel there are 2 standard asp.net panels. Only 1 of these two standard asp.net panels is ever displayed at any one time. The first of the standard panels is used to display the list of results.
When a user selects an item from the list of results to view in full detail, the first standard asp.net panel is made Invisible, and second standard asp.net panel is then made visible, which displays the details of the selected item.
So, the way the two standard asp.net panels (that are contained with the AJAX update panel) work is like a master-detail relationship between the list of results and the details for a particular, selected item.
All of this works fine apart from one aspect.
If the user has scrolled down to an item near the bottom of the list of results, when they select the item to view and the second asp.net panel is then displayed, the browser is still in the same position. This means that the user is then looking half-way down the details, which is obviously not acceptable.
Note: when I say “scrolled down” I mean using the browser scroller – no DIV scrollers are used etc.
What I want to happen is that when the asp.net panel containing the detail is displayed, the browser position should be positioned so that it is at the top of the page.
However, the user can also click a “back to results” link when looking at the details. If this is clicked, then when the panel containing the results is then displayed again, I need the browser to reposition back to where it was originally (i.e., just before the user clicked to view the details of a particular item in the results list).
I’ve looked around in some books and on the web, but the solutions I’ve found there don’t work for this scenario. Of course, we are mainly dealing here with the implications of AJAX and partial page postbacks (for the Update panel).
The site needs to work in IE6, IE7 and (ideally) Firefox.
I would appreciate any help on this because a lack of a solution might mean going right back to the drawing board.
Many thanks,
Darren
|
|
|
|
|
You use a method where the link has a # at the end, then you can direct someone to a specific part of the page i.e. the top. Put the # in a div and then you can direct them to that div by putting a # in the url.
|
|
|
|
|
If you are using any base class then you can write these lines of code
to set the focus on the control which caused asynchronous post back
You will have to write these lines in Pre Render event of the every Page or
Pre render event of base Page
// Set the Focus when there is Asynchronous postback
if (_scriptManager != null && _scriptManager.IsInAsyncPostBack)
{
Control ctrlWhichRaisedAsyncPostBack = Page.FindControl(ScriptManager.AsyncPostBackSourceElementID);
if (ctrlWhichRaisedAsyncPostBack != null)
{
ScriptManager.SetFocus(ctrlWhichRaisedAsyncPostBack.ClientID);
}
}
Let me know if it solves your problem
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hai all,
i had one contact us page in my website,
in that if i click sendmail btn then it will send the mail to the gmail.
and after that out customerservice got the mail in fogbugz.
but i need ,
if we click the sendmail btn then it will send the data to fogbugz API directly.
could any body help me how to do that by using .net?
Thanks
Subbu.
|
|
|
|
|
Can you post your code as it my help us.
You may need to use gmail forum though
|
|
|
|
|
this code is to send comments first to gmail ,after that got the comments in customerservies,i.e fogbugz api.
but i need the comments directly go to the fogbugz api....
not to the gmail.
<dim contactusemailid="" as="" string="ConfigurationManager.AppSettings(" contactusemailid")<br"="" mode="hold"> objCEmail.FromAddress = txtEmailId.Text
objCEmail.MailFromAddress = txtEmailId.Text
objCEmail.ReplyToAddress = txtEmailId.Text
strType = ddlRequestType.SelectedValue
If strType = "Problem with an Order" Or strOrderStatus = "Fail" Then
strType += ":" & txtId.Text
objCEmail.Body = "Problem with an Order:" & txtId.Text
ElseIf strType = "Report Abuse" Then
If ViewState("albumid") IsNot Nothing Then
strType += ":" & ViewState("albumid")
objCEmail.Body = "Report Abuse:albumid=" & ViewState("albumid")
ElseIf ViewState("photoid") IsNot Nothing Then
strType += ":" & ViewState("photoid")
objCEmail.Body = "Report Abuse:photoid=" & ViewState("photoid")
Else
objCEmail.Body = "Report Abuse:Empty"
End If
ElseIf strType = "Marketing/Business Development" Then
ContactUsEmailID = ConfigurationManager.AppSettings("MarketingEmailID")
End If
objCEmail.ToAddress = ContactUsEmailID
objCEmail.Subject = strType
objCEmail.Body += "<br/>"
If Not Session("UserGuid") Is Nothing Then
objUser = UserAccess.GetUser("Guid", Session("UserGuid").ToString)
If objUser IsNot Nothing Then
objCEmail.Body += "User name: " & objUser.UserNickName & "<br/>" '& " (" & objUser.Guid.ToString & ")" & "<br/>"
End If
End If
objCEmail.Body += "Report Info:<br/>"
objCEmail.Body += txtComment.Text
objCEmail.Body += "<br/><br/><strong>User Cookie Info:</strong><br/>"
objCEmail.Body += GetCookieInfo()
Dim str_BrowserType As String = Request.Browser.Browser
Dim str_BrowserVersion As String = Request.Browser.Version
Dim str_PlatForm As String = Request.Browser.Platform
Dim strBrowserInfo As String
strBrowserInfo = "<br/><b>" & "</br><b>BROWSER : </b> " & str_BrowserType & _
"<br/><b>BROWSER VERSION : </b> " & str_BrowserVersion & _
"<br/><b>PLATFORM : </b> " & str_PlatForm & _
"<br/><b>Flash Version : </b> " & hdnFlashVer.Value
objCEmail.Body += "<br/><strong>Browser Info:</strong>"
objCEmail.Body += strBrowserInfo
objCEmail.TransCode = "Contact Us"
objEmailQueue.SendEmail(objCEmail)>
Thanks
Subbu.
|
|
|
|
|
Hi!!..
I have a gridview with Password column.. when i bind that column to the GridView i should get as "***". how can i get that?
thanks
|
|
|
|
|
if you set DataFormatString just * character then all your field will have the single character * and hides the real password, don't know it is helpfull for you! Try it.
I Love T-SQL
|
|
|
|
|
for security reasons, password filed doesn't remember the value entered in it....so it is difficult in dorect case... you need javascript to do so....but that is security hazard
Ashish Sehajpal
|
|
|
|
|
hello friends
I have written validations in javascript ..un-fortunately they are not working...
In my page i am having few text boxes and on a button click i am checking whether the text is "" or not ... and providing a alert box ...
present scenario doesnt allows me to use asp.net validation controls...
thanks in advance ( i can provide the link to site and code too )
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
Is the alert box not showing?
Does the code work in any other browser?
Javascript can be disabled using the browser
|
|
|
|
|
If you are trying to check is the text is ""(empty) then refer to control like this controlname.InnerText with javascritp code.
I Love T-SQL
|
|
|
|
|
its working fine with IE6 ....i will check it with inner text .........
There is one more question for which i am looking for past one day on net its cross browser compatability ..every where it is explained what is it but no where it is written how to solve it ..please tell me how to solve it
Thank You
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
for your question I will suggest you to lookup this result on google [^]I hope you will find the best answer...
I Love T-SQL
|
|
|
|
|
Cross compatability relates to an app working in different browsers.
If an app works in IE and not in mozilla its not always the same reason
sometimes it can be stylesheets, sometimes bits of code like javascript
There is no one way to fix execept by testing your app in multiple browsers as you develop
|
|
|
|
|
I agree with you, I had have problem in style of application when I run on mozilla, it really crashed all design but i fixed it by testing time by time in mozilla.
I Love T-SQL
|
|
|
|
|
thank you.... presently my prob is java script ...any suggestions ...i am using it to show and hide tables on button click ...
thank you
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|