|
I am using temporary gridview. when I delete row in gridview then create a error (There in no position 0) . I am using this code.
Protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DataTable mydt = new DataTable();
Session["dt"] = mydt;
mydt.Rows.RemoveAt(e.RowIndex);
GridView2.DataSource = ((DataTable)Session["dt"]).DefaultView;
GridView2.DataBind();
}
please help me
|
|
|
|
|
Gagan Deep Garg wrote: DataTable mydt = new DataTable();
Session["dt"] = mydt;
mydt.Rows.RemoveAt(e.RowIndex);
GridView2.DataSource = ((DataTable)Session["dt"]).DefaultView;
GridView2.DataBind();
Hi,
here u are creating new Datatable object. And then trying to delete from that. So how it will work ?
You must have data in datatable.
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|
|
I can't seem to get this to work. I just doesn't do anything at all. I've been working on it for about a week and I think I'm doing something fundamentally wrong here. I know I'm executing my Calendar1_DayRender event because when I just make it draw peachpuff for a background color it does it. However I can't get the access to my document to go right. I'm not really sure if it's accessing my document correctly, and the debugger isn't communicating to me. Is there a better way to do this? (such as putting the data-access in a different method and calling it from the event?)
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
XDocument eventsXML = XDocument.Load(Server.MapPath("Events.xml"));
var events = from theevent in eventsXML.Descendants("event")
where theevent.Element("event") != null
select new
{
Organization = theevent.Element("organization").Value,
Creator = theevent.Element("creator").Value,
Name = theevent.Element("name").Value,
Description = theevent.Element("description").Value,
Location = theevent.Element("location").Value,
EventDate = DateTime.Parse(theevent.Element("Date").Element("Day").Value)
};
var thismonth = from item in events
where item.EventDate.Month == DateTime.Now.Month
select item;
foreach (var item in thismonth)
{
if (item.EventDate.Date == e.Day.Date)
e.Cell.BackColor = System.Drawing.Color.PaleVioletRed;
}
}
Example of XML:
"1.0" encoding="utf-8" ?>
<event>
JET
Marti
Mid-Year Conference
Mid-Year Conference
Hachinohe
2007/11/21
8am
event>
<event>
JET
Marti
Mid-Year Conference
Mid-Year Conference
Hachinohe
2007/11/22
8am
event>
<event>
JET
Marti
Mid-Year Conference
Mid-Year Conference
Hachinohe
2007/11/23
8am
event>
|
|
|
|
|
|
Hi,
go to MyArticles. It can help you.
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|
|
the main problem for me is select a row anyway i have done some thing like this
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{string alertBox = "alert(" + e.Row.RowIndex + ")";<br />
e.Row.Attributes.Add("Onclick", alertBox);}
and i got the index of the row but i want the id of the row how can i get the id of the row can you please tell me in detail if possible with example
regards
sunilwise
|
|
|
|
|
Hi,
to get SelectedRow you have to Create an event of TestGridView_SelectedIndexChanged.
Here in this event you can get selected rowindex as well as any cell's value from selected row.
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|
|
thank u ray for u r replies it helped me some what by the way i used javescript function and some code
<script language="javascript" type="text/javascript">
var gridViewCtlId = '<%=gvAuditErrors.ClientID%>';
var gridViewCtl = null;
var curSelRow = null;
function getGridViewControl()
{
if (null == gridViewCtl)
{
gridViewCtl = document.getElementById(gridViewCtlId);
}
}
function onGridViewRowSelected(rowIdx)
{
var selRow = getSelectedRow(rowIdx);
if (curSelRow != null)
{
curSelRow.style.backgroundColor = '#ffffff';
}
if (null != selRow)
{
curSelRow = selRow;
curSelRow.style.backgroundColor = '#99cccc';
alert(rowIdx);
}
}
function getSelectedRow(rowIdx)
{
getGridViewControl();
if (null != gridViewCtl)
{
return gridViewCtl.rows[rowIdx];
alert(rowIdx);
}
return null;
}
</script>
private Int32 m_iRowIdx;<br />
protected void gvAuditErrors_RowCreated(object sender, GridViewRowEventArgs e)<br />
{<br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{<br />
e.Row.Attributes.Add("onclick", "onGridViewRowSelected('" + m_iRowIdx.ToString() + "')");<br />
}<br />
m_iRowIdx++;<br />
}
http://www.netomatix.com/Development/GridViewRowSelectedStyle.aspx[^][^]
|
|
|
|
|
Hi,
I want to use a search criteria within my datagrid. I am havin a textbox within my application wen i m entering some data into it it give me the respective result but i want in such a way that it should show all the records first then after entering some data it will search the record within the datagrid.
Thanking You!
Rock Star
|
|
|
|
|
It's usually a better idea to send your search criteria to your data source and let it do the filtering for you, and your code just handles binding to the data returned
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This is a good Idea for searching I rectnly complete it into my project
the steps are follows....
1.Fill a DataTable and Bind ur grid at first time with this DataTable
2. Set a DefaultView for the above DataTable.
3. And filter this DefaultView with with ur Search Text Box Value...
4. At last Bind ur grid with above DeafaultView in a Search Button Click or any other event...
Hope this we'll help u...
Deepak
Smile a Lots,Its Costs Nothing
|
|
|
|
|
hello everybody
i have a disit or string like.....
9871234567890
i need only last 10 disit or char like
1234567890
how can i do it?
thanks in advance
Sarfarj Ahmed
|
|
|
|
|
dim longString as string = "9870123456789"
dim shortString as string = longString.SubString(3)
You know, you could have probably found out the answer by yourself in less time than it took you to post this!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
This code is properly working;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userID.ToString(),
DateTime.Now, DateTime.Now.AddMinutes(30), false, userRole.ToString(), FormsAuthentication.FormsCookiePath);
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(userID.ToString(), false));
*****But if I use Try-Catch pattern, catch block is running;
try
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(30), false, userRole.ToString(), FormsAuthentication.FormsCookiePath);
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(userID.ToString(), false));
}
catch (Exception ex)
{
Response.Redirect("ErrorPage.aspx");
}
Exception Error Message is;
ex = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
Why I get this message? How can I correct it?
Thanks...
|
|
|
|
|
Accually this code solve my problem;
try
{
//My Code
}
catch (System.Threading.ThreadAbortException ex)
{
//ignore error.
}
catch (Exception ex)
{
Response.Redirect("ErrorPage.aspx");
}
But I think this is not a good solution.
Why do I get this message? How can I correct it?
Best Regards...
|
|
|
|
|
From the MSDN documentation for HttpResponse.Redirect:
'Redirect calls End which raises a ThreadAbortException exception upon completion.'
It is part of the implementation of the Redirect method that a ThreadAbortException is raised. You can catch that particular exception and ignore it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
Please Guys look at my Code,it is working when I click Button1 it lots all the controls that I want inside a repeator,But My problem is that I want the second dropdown inside a repeator to display the value depending/according on the first dropdown selection.How do I go about?
Eg DropDown1 loads all the car name(toyota,audi,bmw)
after selection,maybe (Audi)Dropdown2 load(A3,A4) Who do I go about inside the repeator
Code
Imports System.Net.Mail
Partial Class cap
Inherits System.Web.UI.Page
Dim OSource As Businesslayer.Users = New Businesslayer.Users
Dim rs As Data.DataSet
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New Data.DataSet
Dim obj As Businesslayer.ClientSite = New Businesslayer.ClientSite
Dim NumberOfBoxes As Integer
Dim WhichBox As Integer
Dim rows() As Integer
NumberOfBoxes = Integer.Parse(txtDay.Text) - 1
ReDim rows(NumberOfBoxes)
For WhichBox = 0 To NumberOfBoxes
rows(WhichBox) = WhichBox
Next
Repeater1.DataSource = rows
Repeater1.DataBind()
For WhichBox = 0 To NumberOfBoxes
Dim cmbProjectName As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectName"), DropDownList)
ds = obj.GetProjectNameFromProjAdmin
cmbProjectName.DataSource = ds
cmbProjectName.DataBind()
cmbProjectName.Items.Add(New ListItem("", ""))
cmbProjectName.Items.Item(cmbProjectName.Items.Count - 1).Selected = True
Dim cmbClientSite As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbClientSite"), DropDownList)
ds = obj.GetClientIDFromProjAdmin
cmbClientSite.DataSource = ds
cmbClientSite.DataBind()
cmbClientSite.Items.Add(New ListItem("", ""))
cmbClientSite.Items.Item(cmbClientSite.Items.Count - 1).Selected = True
Dim cmbProjectManager As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectManager"), DropDownList)
ds = obj.GetProjectManagers
cmbProjectManager.DataSource = ds
cmbProjectManager.DataBind()
cmbProjectManager.Items.Add(New ListItem("", ""))
cmbProjectManager.Items.Item(cmbProjectManager.Items.Count - 1).Selected = True
Dim cmbCategory As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbCategory"), DropDownList)
ds = obj.GetCategory
cmbCategory.DataSource = ds
cmbCategory.DataBind()
cmbCategory.Items.Add(New ListItem("", ""))
cmbCategory.Items.Item(cmbCategory.Items.Count - 1).Selected = True
Next
End Sub
Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
Repeater1.FindControl("DropDownList1")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rptErrors As New ValidationSummary
If Page.IsPostBack = False Then
txtProjectMember.Text = Session("Name") & " " & Session("Surname")
txtIDNumber.Text = Session("IdNumber")
txtEmail.Text = Session("Email")
bntSubMana.Visible = "False"
rptErrors.Visible = False
End If
'If Not Page.IsPostBack Then
' rptErrors.Visible = False
'End If
End Sub
Public Sub UserMsgBox(ByVal sMsg As String)
Dim sb As New StringBuilder
Dim oFormObject As System.Web.UI.Control
sMsg = sMsg.Replace("'", "\'")
sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
sMsg = sMsg.Replace(vbCrLf, "\n")
sMsg = "alert(""" & sMsg & """)"
sb = New StringBuilder
sb.Append(sMsg)
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
Controls.AddAt(Controls.Count, New LiteralControl(sb.ToString()))
End Sub
Protected Sub ButtonSubMana_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bntSubMana.Click
Dim ds1 As New Data.DataSet
Dim obj As Businesslayer.TimeSheet = New Businesslayer.TimeSheet
Dim NumberOfBoxes As Integer
Dim WhichBox As Integer
'Dim WeekN As Date
NumberOfBoxes = Integer.Parse(WhichBox)
Dim rows(NumberOfBoxes) As Integer
'Dim Repeater1 As Repeater
For WhichBox = 0 To NumberOfBoxes
'Dim ImageButton1 As ImageButton
Dim txtWeekNumber As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtWeekNumber"), TextBox)
Dim txtDate As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtDate"), TextBox)
Dim cmbProjectName As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectName"), DropDownList)
Dim cmbClientSite As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbClientSite"), DropDownList)
Dim cmbProjectManager As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectManager"), DropDownList)
Dim cmbProjectMember As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectMember"), DropDownList)
Dim cmbCategory As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbCategory"), DropDownList)
Dim cmbOccupation As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbOccupation"), DropDownList)
Dim txtHours As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtHours"), TextBox)
Dim CheckBox1 As CheckBox = CType(Repeater1.Items(WhichBox).FindControl("CheckBox1"), CheckBox)
Dim txtDescription As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtDescription"), TextBox)
Dim errors As ArrayList = New ArrayList
Dim rptErrors As New ValidationSummary
If txtDate.Text = "" Then
errors.Add(New validation("Please Enter your Date"))
End If
If cmbProjectName.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A ProjectName"))
End If
If cmbClientSite.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A ClientSite"))
End If
If cmbProjectManager.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A ProjectManager"))
End If
If cmbCategory.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A Category"))
End If
If cmbOccupation.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A Occupation"))
End If
If txtHours.Text = "" Then
errors.Add(New validation("Please Enter your Hours"))
End If
If txtDescription.Text = "" Then
errors.Add(New validation("Please Enter you Job Description"))
End If
If errors.Count > 0 Then
'rptErrors.DataSource = errors
rptErrors.DataBind()
rptErrors.Visible = True
Else
End If
obj.addTimesheet(Session("Id"), cmbProjectName.SelectedValue, cmbClientSite.SelectedValue, cmbProjectManager.SelectedValue, txtDate.Text, txtWeekNumber.Text, Double.Parse(txtHours.Text), CheckBox1.Checked, cmbCategory.SelectedItem.Value, Session("Userid"), txtDescription.Text, "2")
cmbProjectName.Text = ""
cmbClientSite.Text = ""
cmbProjectManager.Text = ""
cmbCategory.Text = ""
txtDate.Text = ""
txtWeekNumber.Text = ""
txtDescription.Text = ""
txtHours.Text = ""
cmbCategory.Text = ""
Next
'Dim NumberOfEmails As Integer
'Dim NoRows As Integer
'Dim ArrayEmail(20)() As Array
Dim i As Integer
Dim EmailInfo As New Data.DataSet
Dim table As Data.DataTable
Dim row As Data.DataRow
'Dim column As Data.DataColumn
' For each table in the DataSet, print the row values.
For i = 0 To Repeater1.Items.Count - 1
Dim txtWeekNumber As TextBox = CType(Repeater1.Items(i).FindControl("txtWeekNumber"), TextBox)
Dim txtDate As TextBox = CType(Repeater1.Items(i).FindControl("txtDate"), TextBox)
Dim cmbProjectName As DropDownList = CType(Repeater1.Items(i).FindControl("cmbProjectName"), DropDownList)
Dim cmbClientSite As DropDownList = CType(Repeater1.Items(i).FindControl("cmbClientSite"), DropDownList)
Dim cmbProjectManager As DropDownList = CType(Repeater1.Items(i).FindControl("cmbProjectManager"), DropDownList)
Dim cmbProjectMember As DropDownList = CType(Repeater1.Items(i).FindControl("cmbProjectMember"), DropDownList)
Dim cmbCategory As DropDownList = CType(Repeater1.Items(i).FindControl("cmbCategory"), DropDownList)
Dim cmbOccupation As DropDownList = CType(Repeater1.Items(i).FindControl("cmbOccupation"), DropDownList)
Dim txtHours As TextBox = CType(Repeater1.Items(i).FindControl("txtHours"), TextBox)
Dim CheckBox1 As CheckBox = CType(Repeater1.Items(i).FindControl("CheckBox1"), CheckBox)
Dim txtDescription As TextBox = CType(Repeater1.Items(i).FindControl("txtDescription"), TextBox)
Dim EmailMessage As String
For Each table In EmailInfo.Tables
For Each row In table.Rows
' Response.Write(row(0) + " " + row(1))
Dim from As MailAddress = New MailAddress("timesheet@ecominstitute.com", Session("Name") & " " & Session("Surname"))
Dim recieve As MailAddress = New MailAddress(row(0), row(1))
EmailMessage = " Dear " & row(1) & "
" & _
"This is to notify that the TimeSheet for this week is as follows :
" & _
" " & _
"Date | Project Name | Client Site | Hour | Description | " & txtDate.Text & " | " & cmbProjectName.SelectedItem.Text & " | " & cmbClientSite.SelectedItem.Text & " | " & txtHours.Text & " | " & txtDescription.Text & " | "
Dim message As MailMessage = New MailMessage(from, recieve)
message.Subject = "Weekly TimeSheets For :" & txtProjectMember.Text
message.IsBodyHtml = True
message.Body = EmailMessage
'Dim copy As MailAddress = New MailAddress("Notification_List@contoso.com")
'message.CC.Add(copy)
Dim client As SmtpClient = New SmtpClient("srjhbex01", 25)
client.Send(message)
Next row
Next table
Next
UserMsgBox("Your Time-Sheet has been to the Manager for Approval")
End Sub
Protected Sub txtDay_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDay.TextChanged
Dim bntPrint As New Button
If txtDay.Text <= 0 Then
Repeater1.Visible = False
UserMsgBox("Please Enter the Number Greater than 0")
Else
Repeater1.Visible = True
bntSubMana.Visible = "True"
End If
End Sub
End Class
|
|
|
|
|
Hello I have a string variable declared in a Webform
Is there a way in which I can modify the value of that variable with javascript?
can I use something like getElementById, or something that can allow me to get that variable?
thanks
|
|
|
|
|
It's a server side variable (declared in the C# code),the answer is no. You can use for instance a hidden field , and in a postback get that value.
/// -------------------------
Braulio Díez
tipsdotnet.com
/// -------------------------
|
|
|
|
|
Really???
Well, I'll live
thanks man
|
|
|
|
|
I'm exporting a datagrid to excel. I use itemCreated and OreRender to change the rows and put more header rows but when i export the changes don't appear in the excel.
Nzibi
|
|
|
|
|
|
Hi,
I need to work on a requirement that like MaskTextBox that in window.
Actual requirement is I have to diplay the Time in a single text box in HH:MM:SS format with two buttons increment and decrement. It is very similar to DateAndTime Properties window of Windows. It is any possiblites to do that in ASP.NET.
Thanks in Advance
Regards
Prakash.A
Good Is Not Good When Better Is Expected.
|
|
|
|
|
A AntonySP wrote: It is any possiblites to do that in ASP.NET.
ASP.NET can't do anything on this because it works on the server. You may do this using JS. AFAIK, no built-in controls available for such a requirement.
|
|
|
|
|