|
While you've been given fair advice on how to do this, I must urge you to consider the edge cases in your code. What happens if your user enters 1? Substring(0,2) will fail. What happens if they don't enter anything at all? What if they enter " 1"? Please ensure that your code copes with cases like these:
public void FilterDepartments(string input)
{
if (string.IsNullOrEmpty(input)) return;
string filter = input.Trim();
if (filter.Length > 1)
filter = filter.Substring(0, 2);
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have a problem with telerik rad controls.I have a grid called MASTER_GRID and while selecting a row from that grid the corresponding SUB_GRID will load.same MASTER_GRID i am using in RadAjaxmanger as one of the control.when i am using the MASTER_GRID with RadAjaxcontrol, the "ROWCLICK" event which is in the MASTER_GRID is not firing..shall i add anything in the RadAjax manager to anable row click for the master grid??
|
|
|
|
|
Hi,
i need to create a dynamic row for HTML table in my asp.net application on every button click, i have tried many ways, but most of the cases, viewstate is not maintaining(for dynamically created row), and meanwhile i need to save these rows into database.
Please help me, if anybody knows...
Thanks in advance
|
|
|
|
|
|
Thanks, but it is not maintaining the viewstate, i need viewstate also, i want to save all the data in the database.
|
|
|
|
|
Hi,
I want links for alphabet A-Z,when click that letter i want filter and dispaly into gridview..
Can anybody give suggestion to do?
|
|
|
|
|
Try This , if anu probs let me know
create Datalist dlist_chars in design
<asp:DataList ID="dlist_chars" Width="100%" CellPadding="5" CellSpacing="5" DataKeyField="PageIndex"
runat="server" RepeatColumns="26" RepeatDirection="Horizontal" OnItemDataBound="dlist_chars_ItemDataBound">
<ItemTemplate>
<asp:LinkButton CssClass="detail_link" ID="lnl_chars" OnClick="LinkButton1_Click"
CommandArgument='<%# Eval("PageText") %>' runat="server" Text='<%#Eval("PageText")%>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
private void CreateAlpha()
{
DataTable dt = new DataTable();
dt.Columns.Add("PageIndex");
dt.Columns.Add("PageText");
if (this.ViewState["Paging"] == null)
{
for (int i = 65; i <= 90; i++)
{
DataRow dr = dt.NewRow();
dr[0] = Char.ConvertFromUtf32(i);
dr[1] = Char.ConvertFromUtf32(i);
dt.Rows.Add(dr);
}
this.ViewState["Paging"] = dt;
}
else
dt = (DataTable)this.ViewState["Paging"];
dlist_chars.DataSource = dt;
dlist_chars.DataBind();
}
on link buton click in datalist
protected void LinkButton1_Click(object sender, EventArgs e)
{
LinkButton myButton = sender as LinkButton;
if (myButton != null)
{
string text =(myButton.CommandArgument);
clsEmployee emp = new clsEmployee();
emp.empID = 1;
if (text == "| All")
{
emp.empName = "%";
}
else
{
emp.empName = text;
}
DataSet ds = new DataSet();
// fetcha reccord from another datalist dlist_record then bind
dlist_record.DataSource = ds;
dlist_record.DataBind();
}
}
|
|
|
|
|
If you format your code it'll increase the readability.Now its looking odd.Thank you.
|
|
|
|
|
call function CreateAlpha() in pageload
|
|
|
|
|
Hi,
Please let me know how can i convert
string x="10000000000" to int...
i tried Convert.Int64 but im getting exception that number is too long or too short to store value in INt32..
|
|
|
|
|
I think the number is exceeding the limit of Int32 or Int64
try following code for successfully converting your string to
number
If number >= Int32.MinValue And number <= Int32.MaxValue Then
newNumber = Convert.ToInt32(number)
Console.WriteLine("Successfully converted {0} to an Int32.", _
newNumber)
Else
Console.WriteLine("Unable to convert {0} to an Int32.", number)
End If
You can use the same logic for Int64.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
i think maxvalue for Int64 is 9,223,372,036,854,775,808 which is greater than 10000000000
|
|
|
|
|
pradeep455 wrote: i tried Convert.Int64 but im getting exception that number is too long or too short to store value in INt32..
The error says number is too long or too short to store value in Int32..
So I think you are trying with Int32.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
even i tried with Convert.Int64 also..same error..
and im stroing in Int64 variable..still im getting the error..
|
|
|
|
|
Try using the int64 parser
Int64.Parse(string input)
Best Regards
HE
|
|
|
|
|
ya even that was not working...
|
|
|
|
|
"Was" not working or "is" not working?
The above mentioned solution (int64 + parse) works fine.
Tested:
string test = "10000000000";
System.Int64 int64 = Int64.Parse(test);
and it is totally ok.
|
|
|
|
|
Hi...
I have binary data using image datatype for uploading audio files.-C#
But i can't retrieve it. How can i retrieve it?
Kindly help to resolve this issue.
Thanks,
PUJA FALDU
|
|
|
|
|
|
Thanks for response...
i have tried as you suggest links.
but then also its not working properly... its says that file is currepted...
|
|
|
|
|
When you say "it" says the file is corrupted we have no idea what "it" is. Is it media player? Is it iTunes? We also don't know what you are doing after retrieving the data from the database. Are you streaming to a browser? Are you saving to a file?
|
|
|
|
|
hi..
i am streaming to browser.... how can i do this task?
Thanks.
PUJA FALDU
|
|
|
|
|
Are you sure the player you have supports the codec the file is recorded with? Have you tried saving the file to the filesystem both before saving it to the database and after retrieving from the database rather than streaming and seeing if that works? If the file is corrupted you need to try some debugging steps to track down exactly when in the process the corruption is ocurring.
|
|
|
|
|
Hi
In My application, I am Using Model PopUP
In which data are coming in a grid with paging.
But Problem is that when I am Clicking on 2nd paging, Page Model popup
Become Closed, So Is there any way to stop that model popup,
My model popup is in Update panel
thanks in Advanced
|
|
|
|
|
You're using the ModalPopupExtender from the AjaxToolKit, right? If so, the problem is the occurring postback while paging.
Although i remember that there was a better solution than mine, i unfortunately dont remember the solution itself..So heres mine:
Either put the content of your popup in a seperate updatePanel (if that works for you), or call the Show method of your popupextender
again in the paging event. This way it should stay open (at least i'm doing this somewhere in a click-event of a button and this way it stays open).
Hope this helps somehow.
|
|
|
|