|
I am using Asp.net 2.0 there is no datagrid anymore. Thanks for your reply
|
|
|
|
|
Hi,
Have you put the dropdown list in the gridview or outside the gridview?
If its outside then you can create an event handler to handle SelectedIndexChanged event of DropDownList and filter data there and bind the gridview again.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
The dropdown is outside of the gridview. This is asp.net 2.0 not 1.1. So I initially bind the gridview do accessdatasource. And then inside gridview there is a datasourceid property. So I knew how to rebind in asp.net 1.1 I don't know how to rebind in asp.net 2.0.
Thank you
|
|
|
|
|
Hi,
You can create your AccessDataSource with parameters and on the click event of button you can provide value that parameter.
The following is the example of parameterized AccessDataSource
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Northwind.mdb" SelectCommand="SELECT [ProductID], [ProductName], [CategoryID] FROM [Alphabetical List of Products] WHERE ([CategoryID] = ?)">
<SelectParameters>
<asp:Parameter Name="CategoryID" Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>
Here AccessDataSource1 has one parameter "CategoryID" which will need a integer value. Also you can see the WHERE clause in the SelectCommand Property of the AccessDataSouce1.
The following code shows you how a value is assigned to the paramter of AccessDataSource1 and GridView is rebounded.
protected void Button1_Click(object sender, EventArgs e)
{
AccessDataSource1.SelectParameters[0].DefaultValue =
ddlCategories.SelectedValue;
GV.DataBind();
}
Here ddlCategories is the dropdownlist whose value I am passing to the parameter of the AccessDataSource1.
I hope this will help you.
-- modified at 2:01 Tuesday 24th April, 2007
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi, thank you for such a detailed reply. One issue is that you included the code in a button event handler. I have no button. Rather once an item was selected from an dropdown category the viewgrid should be rebound. Maybe I didn't clearly understand your explanation.
Thank you.
|
|
|
|
|
Hi,
If you want your grid to be rebound when an item is selected in the dropdownlist, then you should write the code in the "SelectedIndexChanged"
event of the DropDownList.
protected void ddlCategories_SelectedIndexChanged(object sender, EventArgs e)
{
AccessDataSource1.SelectParameters[0].DefaultValue =
ddlCategories.SelectedValue;
GV.DataBind();
}
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Thank you. I will try it. But I understand the solution. It seems that it got even simpler in asp.net 2.0. I assumed you have to create a datasource and then assign it to the gridview. And from what I see you just wrote gv.databind()
Thanks alot for your assistance.
|
|
|
|
|
Hi,
No need to say thanks.
One thing I would like to remind you that dont forget to set "AutoPostBack" property of DropdownList to "true".
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
hi guys,
i have a problem. I have two gridviewss say A and B. gridview A has many records. on selecting a particular record, tht record shud be moved in the gridview B. in this way gridview B has all records selected from A.How am i suppposed to do so. Need ur help.
Thnx in advance.
|
|
|
|
|
cud any one help in how to get field type of table through coding..?
|
|
|
|
|
I would suggest you to use typed dataset to get such information !!!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
could any one help me how to change the page type like the one usually comes for printing etickets, with only borders no toolboxand all...?
got it r am i confusing..?
Help me plsss...
|
|
|
|
|
Can you explain some more on your problem ?
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
window.open("MyUrl.aspx","srch",'toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,status=0,resizable=1,top=10,left=10')
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
thanx for ur reply.... but it dint works.... i'm using C# in ASP.NET 1.1....
would tat works for it..?
|
|
|
|
|
Sorry, should've been clearer. It's a little bit of javascript. You have 2 options - either in the markup of your page, put a script tag with a function defined that just calls window.open, or alternatively, you can use the Page.RegisterStartupScript or Page.RegisterClientScriptBlock to emit it to the page, and it will then be run at the appropriate time.
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Hi all,
I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which contains information About CustomerName, CustomerType, Address, City. These 4 colum values should populate the 4 Dropdown lists. And then I need to implement those 4 dropdowns like this. When the user selects a Customername it should display relevant customer information in the GridView. Or when the user selects values from all 4 listboxes it should display all information on GridView as well.
For all the above I have just populated one listbox but I don't know how to populate the other 3 dropdown lists and implement them on the web form.
I have created one method in the Data Access Layer class and one method in the Web Service class and then I instaitiated the web service object in the web form by adding a web reference. It works fine for just populating one dropdown list box but for the whole 4 dropdown list I am unable to populated and Implement them.
Below are the methods and the code for one dropdownlist.
(1)Web Form code:
WebService.Service ws = new WebService.Service();
protected void Page_Load(object sender, EventArgs e)
{
object[] alist;
alist = ws.GetBusinessType(string.Empty);
DropDownList1.DataSource = alist;
DropDownList1.DataBind();
(2) Web Service Method:
[WebMethod]
public ArrayList GetBusinessType(string btype)
{
DAccess ODA = new DAccess(); //Data Access object
ArrayList list = new ArrayList();
list = ODA.GetBusinessType(btype); //Data Access method
return list;
}
(3) Data Access method:
public ArrayList GetBusinessType(string btype)
{
SqlConnection connection = GetConnection;
try
{
ArrayList arrbt = new ArrayList();
StringBuilder sql = new StringBuilder()
.AppendLine("SELECT")
.AppendLine("\tTYPENAME")
.AppendLine("\tFROM")
.AppendLine("\tBUSINESS_TYPE");
SqlParameter paramTYPENAME = new SqlParameter("TYPENAME", SqlDbType.NVarChar);
paramTYPENAME.Value = btype;
connection.Open();
SqlDataReader reader = ExecuteQuery(connection, sql.ToString(), paramTYPENAME);
while (reader.Read())
{
string result = reader["TYPENAME"].ToString();
arrbt.Add(result);
}
return arrbt;
}
catch (Exception ex)
{
return null;
//do some log here Call a class that logs the errors
}
finally
{
connection.Close();
}
All the above code works fine for just populating the one dropdown list but not implementing. I just want the implementation something like....When the user select one dropdown or all of them then it should display the result in the gridview. I have not shown the aspx code here but the main thing is the code above. Can any one help me to implement this
I really appreciate your help. Looking forward to your reply.
Thanks
Koonda
|
|
|
|
|
Hi,
According to me u should create event handlers to handle "SelectedIndexChanged" event for all your dropdownlists and should write code there to bind the gridview.
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Thanks Chetan Ranpariya,
But the thing is I have a Display button below the 4 dropdowns and when I select each dropdown and click the display button it should display all the relevant information. I have populated the dropdowns but the question is how to implement them through the Web Service. I have a method in my Web Form which calls a method in the Web Service and this Web Service method calls another method in The Data Access Layer which has all the SQL stuff. But I have problem of how to Implement the Data Access Layer in order to get the values from Database and return it to Web Service and then the Web Service return it to the Web form and it is displayed there in the GridView.
Could you send me any code examples that would be very nice.
Thanks a lot for your help and looking forward to your reply.
Koonda
|
|
|
|
|
I have created a web page using C#.net 2005. The web page contain a textbox which is disabled. And the web page contain a button, after clicking the button, there will be a pop-up window containing calender. When the user select the date in calender, the window will be closed and return the selected value back to the textbox which is disabled. The date will appear on the textbox but after refresh the value is missing.....I cannot figure it out... Please kindly help. I deeply appreciated for your help.
|
|
|
|
|
When a form field is disabled, it won't be included when the form is posted. If you want the data to be sent to the server, you have to put it in a field that is not disabled. You can for example put it in a hidden field.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi
Modify your page 'form' tag like this..
'submitdisabledcontrols' is new feature in ASP.NET 2.0
Hope this Helps
Thanks..
|
|
|
|
|
am Using a TextBox and ListBox Under Update Panel (control of asp.net ajax). I am Populating the Listbox according to the text in textBox.
I have declared Onchange Event of textBox and in that function I have Populated the ListBox.But How can I do the same task with onkeydown event
or onkeypress event of TextBox? As there is no server event named onkeydown or onkeypress exists ?
monir
|
|
|
|
|
You need to use javascript for keypress event
|
|
|
|
|
I'm looking for a web library/control that will allow me to Resize, Convert and Save images to disk or DB upon submit. I'm running a site where users can submit photos and I want to convert them all to WIDTH x HEIGHT and if the are anything other than JPG/JPEG convert them to be JPG.
Anyone have suggestions for a product they have used?
Thanks,
Rex Winn
|
|
|
|