And do you mean looping through the resultset returned that is returned from the database or looping in sql statement.
And do you mean looping through the resultset returned that is returned from the database or looping in sql statement.
I copied and run your code on my computer. It works fine on my computer may be your database doesn't consist of data which is extracted on the basis of filter from dropdownlist.
what exactly are you referring to. You already got your gridview filled with the record's based on the filter value from the dropdownlist.
Are you looking for looping in sql or in c#.
Sorry man, i am confused.
Above code is very simple. If this is not the thing you want. Cheer up man, just let me know. I have other options as well.
If you want to display the item in gridview with the item selected in dropdownlist on selected index change of dropdownlist, then here is your code to do this.:)
First declare a dropdownlist and Gridview in the aspx web page like shown below:
<div>
<asp:DropDownList ID="ddItems" runat="server" Width="100px" OnSelectedIndexChanged="ddItems_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="11" Value="11"></asp:ListItem>
<asp:ListItem Text="12" Value="12"></asp:ListItem>
<asp:ListItem Text="13" Value="13"></asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
</div>
Then for initial loading of the gridview and to load gridview with the item selected in the dropdownlist on selected index change of dropdownlist write the following code in the code-behind:
//Declare ArrayList object al in the class
ArrayList al;
protected void Page_Load(object sender, EventArgs e)
{
//For initial loading of gridview
al = new ArrayList();
al.Add("test");
al.Add("test1");
GridView1.DataSource = al;
GridView1.DataBind();
}
protected void ddItems_SelectedIndexChanged(object sender, EventArgs e)
{
//to load the gridview with the item selected in gridview
al.Clear();
al.Add(ddItems.SelectedValue);
GridView1.DataSource = al;
GridView1.DataBind();
}
I think this will solve your problem. If not the contact me anytime.
If this solved your problem, please mark it solved. I hope you understand, it will be motivation for us.
Thanks,
Do you want selected item in the dropdownlist to be displayed in the gridview or fetch some item from a data source based on the selected item in the dropdownlist and display it in the gridview.
You question is not clear. Please be precise.
To check multiple check boxes you must have it at first. But i don't see it in your code. If you try to check multiple check boxes with the same GroupName from codebehind it will allow you to do so but if user tries to select multiple checkboxes with the same group name in the web page it will just not happen.
Well, checking length in asp.net is not quite easy. But you can restrict user from entering characters more that allowed limit.
set the MaxLength property of textbox to the number of characters you want to allow.
Well the draw back of this method is that, it does not display any error to the user that they are entering more characters than allowed.
But you will not need to display. the error.
I did this several times and it is working.
or you can use javascript to validate.
Then i guess you have written wrong SQL Statement to extract the deliveryboy names in this part of the code as you have written:
SelectCommand="SELECT [StaffID] FROM [StaffRegis_Table] where designation=@designation">
but it should be written as below:
SelectCommand="SELECT [StaffID] FROM [StaffRegis_Table] where designation='deliveryboy'">
All i want to say is that you are using a parameter "@designation" to be passed the sqlstatement. Don't do that, directly pass the value to the "designation" of where condition as shown above in my code suggestion.
From where are you supposed to provide the value for Where condition i.e @designation for the SqlDataSource of DropDownlist. Giive it a thought.
I am online now, i can help you immediately.
and what do you mean by statement "At the same time how to only display rows of selected gridview only." Please be precise.
First solve your problem of "Must declare the scalar variable "@designation"" and then we will look at the other problem.
so make the textbox readonly and it will be readonly
simple isn't it
well, your problem was to load the page in new window.
Which you did successfully.
Did you use the page_load event of new page. Try to get the value from the query string in the page_load event and then load the gridview in the Page_Load event.
This should probably work . I will sure look over this problem.
Your problem of opening new page from the code behind was solved. So you should mark this thread as solved and start new thread.
Dont forget to enclose your code in code tags like this:
[code=C#] Response.OpenNewDamnPage("DeviceInformation.aspx?arg=" + e.CommandArgument);
[/code]
this will display as
Response.OpenNewDamnPage("DeviceInformation.aspx?arg=" + e.CommandArgument);
Use this exactly for your case:
protected void button1_Click(object sender, EventArgs e)
{
Response.Write("<script type='text/javascript'>window.open('DeviceInformation.aspx?arg=" + e.CommandArgument + "','_blank');</script>");
}
Hey
Try This
protected void button1_Click(object sender, EventArgs e)
{
Response.Write("<script type='text/javascript'>window.open('NewPageUrlWithArgument.aspx','_blank');</script>");
}
This sure will work
If it solves your problem mark the thread as solved.
use EditItemTemplate and in the EditItemTemplate make only the field you want editable as editable . for the rest use labels to show the fields or readonly textboxes.
<FAKE SIGNATURE>
A Software Development Company
or contact me at <FAKE SIGNATURE> , send me comment or subscribe to my blog or follow me.