|
Hi friends,
I want to create drop down lists for all the rows of a gridview. But i dont want to use TemplateField because i want to give different id's for all drop downs. Can anybody help me please.
scarface
|
|
|
|
|
Hi friend,
Can u provide yr exact requirement, like why u need to give unique ID to all Dropdown list at server side. So that i can help u.
And what problem u have with TemplateField?
Regards
Anil Pal
|
|
|
|
|
Hi,
I am trying to create two sets of drop down lists in a gridview. If i change the index of the first drop down, the values of the corresponding drop down should change. I used event handler for the first drop down, but if i change the index of any one of the drop downs in the first set, all the values of second drop downs are getting changed.
scarface
|
|
|
|
|
Hi,
Now i understand yr problem. So the initialization of second set of dropdown list u can not stop, while changing of index of first set of drop down list.
So to maintain the state of the second dropdown set. First u need to take the state of all the dropdown list from second set and the again u need to set their state while changing the index of first one.
Now please let me know if you code for that or any query.
Regards
Anil Pal
|
|
|
|
|
Please have a look at my code:
<asp:GridView ID="grd" runat="server" OnRowDataBound="grd_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="names">
<ItemTemplate>
<asp:DropDownList ID="name" runat="server" OnSelectedIndexChanged="onSelectChangeddl"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="age">
<ItemTemplate>
<asp:DropDownList ID="age" runat="server" AutoPostBack="true">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
In c# code, i am trying to change the values of the second drop down list based on the value selected in the first. I am doing this as below:
foreach (GridViewRow row in grd.Rows)
{
DropDownList ddl1 = (DropDownList)row.FindControl("name");
DropDownList ddl = (DropDownList)row.FindControl("age");
if (ddl.SelectedValue.ToString() != "---Select---")
{
}
else
{
ddl.Items.Clear();
}
SqlCommand SPComm = new SqlCommand("someStoredProcedure", myConn);
SPComm.CommandType = CommandType.StoredProcedure;
SqlParameter param = SPComm.Parameters.Add("@something", SqlDbType.NVarChar, 50);
param.Value = something;
dr = SPComm.ExecuteReader();
int i = 0;
while (dr.Read())
{
ddl.Items.Insert(i, dr.GetString(0));
}
dr.Close();
ddl.Items.Insert(0, "---Select---");
}
In the above code, all the values in the second drop down list are getting duplicated based on the selected index changed event handler of the first drop down list.
scarface
|
|
|
|
|
Hi,
I have gone through the your code.
int i = 0;
while (dr.Read())
{
ddl.Items.Insert(i, dr.GetString(0));
}
dr.Close();
In the above code where u increment the I . According to yr code there always i=0. Hence it replicate the value. Why u can not use Datatable or dataset. Howevere using of Collection of object is good choice.
Regards
Anil Pal
|
|
|
|
|
i have a task in which
have to rewrite url on post back
on grid view paging
url : ~/abc.aspx
on page index change
url: ~/abc.aspx/page1
|
|
|
|
|
Hi,
Have u try to rewrite the on "PageIndexChanging" event of GridView.
Regards
Anil Pal
|
|
|
|
|
i want when gridview page index change the page url show page no
as
abc.aspx
on postback(on changing new page index of grid view)
abc.aspx/p2
or
abc.aspx?p2
|
|
|
|
|
I am planning to implement my project using 3-tire arch ... please guid me
Ramkumar
|
|
|
|
|
That's a huge topic. Read books and articles on-line. Come back with specific questions.
|
|
|
|
|
getramonweb wrote: I am planning to implement my project using 3-tire arch ... please guid me
Read Some Article from Net on that.
You can
Start With This[^]
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
|
Hi, In my website there is a file upload page, where users upload some files.
I have another web applications where i have to develop a page to view the previously uploaded files.
the problem is that the files are in another directory.
Can anyone solve my problem?
Thanks and regards
ARINDAM
|
|
|
|
|
|
thanks for your response Matthew...
But this is not my solution.
I am explaining my problem a bit elaborately.
My fileupload web application uploads file in say : c:/Directory1.
But the web application where users views the files are in d:/Directory2.
I am listing the uploaded files in a listbox control... which I am being able to do.
Now when a user clicks one item in listbox it just sets the "href" attribute of an hyperlink with "c:/Directory1/" + filename.
But since the files are on another directory, when I click on the hyperlink it does not respond,but on the browser window status bar I can see the path which is assigned to it's href attribute and it's proper.
ARINDAM
|
|
|
|
|
That shows you have no idea on web applications. Physical path like c:/directory will not work with web applications. It can access only directories which are under it's website space. So you have to keep your upload files in a directory inside your website area.
|
|
|
|
|
I have just done it making an ftp site
ARINDAM
|
|
|
|
|
hi try this
using System.IO;
and
String DocPath = Session["DocPath"].ToString();
//here Docpath = "~/Documents/18abc.jpg"
string path = Server.MapPath(DocPath);
//here path = "Y:\\testsite\\Myfolder\\Documents\\18abc.jpg"
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Image1.ImageUrl = path;
//or you can use direct path
Image1.ImageUrl = "htt://www.yoursite/folder/file.jpg";
}
this may help you
|
|
|
|
|
Hi,
I m using ajax modal pop up extender control in my ASP.Net 2008 website. On click of some option button it opens up the modal pop disabling the base page. Although it disables the page ... mouse clicks does not work but tab key do work on the base page if there are option buttons on the page.
Can anyone give a suggestion or solution to disable the option buttons on base page through tab keys? Or if there is any other solution for opening pop up windows in asp.net website?
I also want to open another modal pop up from a modal pop up itself. Is it possible ? caz when i use it, it behaves weirdly i.e. does not work properly.
Thanks,
|
|
|
|
|
i tried to response.redirect() to main page , in the session end event, but in that event get a exception saying "Response is not available in this context"
how can i handle this situation
|
|
|
|
|
|
Hi all
I am using ASP.Net 3.5 and send email using smtp server
when i host my application i am getting the below error:
The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for name@domain.com
My Code:::
Dim objMail As New MailMessage
Try
objMail.From = "name@domain.com"
objMail.To = "name@domain.com"
objMail.BodyFormat = MailFormat.Text
objMail.Priority = MailPriority.High
objMail.Subject = "My first ASP.NET email"
objMail.Body = "This is my first email sent via "
SmtpMail.SmtpServer = "server ip address"
SmtpMail.Send(objMail)
Catch ex As Exception
Response.Write(ex.Message)
End Try
Thanks in advance
Er. Jagwinder Singh
|
|
|
|
|
You may need to authenticate to your email server so you would need to add that to your code. Below is a code snippet using cdosys, that i tested answering a similar question the other day.
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="youremail@yourdomain.com"
myMail.To="youremail@yourdomain.com"
myMail.TextBody="This is a message."
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="youremailserver"
'Server port
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
'authenticate
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'email address for authentication
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youremailaddresshere"
'email password
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "youremailpasswordhere"
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
Hope this helps
|
|
|
|
|
Hi,
I am building a ASP.NET page using c#.
I need a code to add a javascript function to disable a button on a text change event.
The below is the code i wrote
The script code in tags:
function SetButtonStatus()
{
document.getElementById("Button2").disabled = true;
}
this is the textbox tag:
<asp:textbox id="txtName" runat="server" onchange="SetButtonStatus()" xmlns:asp="#unknown">
It doesn't seem to work. Please help me on this one.
|
|
|
|